IQSS/dataverse#7895 prevent clearing fields in dataset form when hitting enter#8488
IQSS/dataverse#7895 prevent clearing fields in dataset form when hitting enter#8488haarli wants to merge 4 commits intoIQSS:developfrom
Conversation
…et_form' into IQSS/7895_hitting_enter_in_dataset_form
sekmiller
left a comment
There was a problem hiding this comment.
This looks like a good approach and I've found that it works for Chrome and Firefox, but it doesn't work for Safari. A quick look on my part didn't yield a solution for Safari.
|
Thanks for the review, didn't check with Safari. Safari seems to ignore submit buttons with "display=none" when it comes to hitting the enter button inside the form (same goes for buttons with the HTML5 attribute "hidden"). Firefox and Chrome do not. So even without this PR, there's currently a different behaviour when hitting enter in any single-line text field in the datasetForm. And there's also a difference between creating a new dataset and editing: Current behaviour
Behaviour with PRClearing all input is worst case. So with this PR, in Firefox and Chrome nothing would happen when pressing enter (for create and edit). In Safari, "save" would be triggered (for create and edit). |
|
I found this bit of jquery which seems to work on Firefox, Chrome and Safari: |
|
The problem with this JS snippet is that it prevents any usage of the enter button in the form, e.g. newlines in the description field wouldn't be possible anymore. |
|
I was thinking about this solution: #8500 |
|
Thanks for the alternative solution. Looks good. |
|
I'm going to close this in favor of Erik's solution. Thanks for your contribution. |
This pull request closes #7895.
It adds a dummy button with no functionality to the beginning of the dataset form. This way, when pressing enter in a single text field of the form, nothing happens. Before, all fields in the form were cleared, which is an undesired behaviour.