Permalink
Browse files

BUGFIX Disable form submits through "enter" key in CMS, as they might…

… trigger unwanted actions by the browser choosing the default button
  • Loading branch information...
1 parent 2288d80 commit ca789ef5ffade7d5a9d06850d6c22a5ad69f4281 @chillu chillu committed May 1, 2012
Showing with 6 additions and 11 deletions.
  1. +6 −11 admin/javascript/LeftAndMain.EditForm.js
View
17 admin/javascript/LeftAndMain.EditForm.js
@@ -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
*

0 comments on commit ca789ef

Please sign in to comment.