Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MINOR Moving edit form focus logic from onadd() to onmatch() to give …

…the form time to become visible (see #7258)
  • Loading branch information...
commit 2fa835a0272e45949c98753386802dd47d20fb5f 1 parent ecb48bb
@chillu chillu authored
Showing with 12 additions and 7 deletions.
  1. +12 −7 admin/javascript/LeftAndMain.EditForm.js
View
19 admin/javascript/LeftAndMain.EditForm.js
@@ -68,12 +68,6 @@
// in order to avoid changing the menu state if the action is cancelled by the user
// $('.cms-menu')
- // focus input on first form element. Exclude elements which
- // specifically opt-out of this behaviour via "data-skip-autofocus".
- // This opt-out is useful if the first visible field is shown far down a scrollable area,
- // for example for the pagination input field after a long GridField listing.
- this.find(':input:visible:not(:submit)[data-skip-autofocus!="true"]:first').focus();
-
// Optionally get the form attributes from embedded fields, see Form->formHtmlContent()
for(var overrideAttr in {'action':true,'method':true,'enctype':true,'name':true}) {
var el = this.find(':input[name='+ '_form_' + overrideAttr + ']');
@@ -110,7 +104,18 @@
this.changetracker('destroy');
this._super();
},
-
+ onmatch: function() {
+ this._super();
+
+ // focus input on first form element. Exclude elements which
+ // specifically opt-out of this behaviour via "data-skip-autofocus".
+ // This opt-out is useful if the first visible field is shown far down a scrollable area,
+ // for example for the pagination input field after a long GridField listing.
+ this.find(':input:not(:submit)[data-skip-autofocus!="true"]').filter(':visible:first').focus();
+ },
+ onunmatch: function() {
+ this._super();
+ },
redraw: function() {
if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
Please sign in to comment.
Something went wrong with that request. Please try again.