mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Disable form submits through "enter" key in CMS, as they might trigger unwanted actions by the browser choosing the default button
This commit is contained in:
parent
2288d80c30
commit
ca789ef5ff
@ -142,21 +142,16 @@
|
||||
* Suppress submission unless it is handled through ajaxSubmit().
|
||||
*/
|
||||
onsubmit: function(e, button) {
|
||||
this.closest('.cms-content').submitForm(this, button);
|
||||
// Only submit if a button is present.
|
||||
// This supressed submits from ENTER keys in input fields,
|
||||
// which means the browser auto-selects the first available form button.
|
||||
// This might be an unrelated button of the form field,
|
||||
// or a destructive action (if "save" is not available, or not on first position).
|
||||
if(button) this.closest('.cms-content').submitForm(this, button);
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
onkeydown: function(e) {
|
||||
if(e.which == 13) {
|
||||
// Submit the form with the first action button if enter key is pressed.
|
||||
// Avoids browsers auto-selecting the first button available,
|
||||
// which might be on a form field, e.g. an UploadField popup trigger.
|
||||
var btn = this.find('.Actions .action:first');
|
||||
this.trigger('submit', e, btn);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Function: validate
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user