Permalink
Browse files

BUGFIX Choose first "action" button on submission of CMS forms via en…

…ter key, to avoid a form field button being autoselected (fixes #7151)
  • Loading branch information...
chillu committed Apr 30, 2012
1 parent 517a0c9 commit 85a331cc11caa59f04675da3834fce8435a86ec6
Showing with 10 additions and 0 deletions.
  1. +10 −0 admin/javascript/LeftAndMain.EditForm.js
@@ -147,6 +147,16 @@
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 85a331c

Please sign in to comment.