Skip to content
This repository
Browse code

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
Ingo Schommer authored June 14, 2012

Showing 1 changed file with 12 additions and 7 deletions. Show diff stats Hide diff stats

  1. 19  admin/javascript/LeftAndMain.EditForm.js
19  admin/javascript/LeftAndMain.EditForm.js
@@ -68,12 +68,6 @@
68 68
 				// in order to avoid changing the menu state if the action is cancelled by the user
69 69
 				// $('.cms-menu')
70 70
 				
71  
-				// focus input on first form element. Exclude elements which
72  
-				// specifically opt-out of this behaviour via "data-skip-autofocus".
73  
-				// This opt-out is useful if the first visible field is shown far down a scrollable area,
74  
-				// for example for the pagination input field after a long GridField listing.
75  
-				this.find(':input:visible:not(:submit)[data-skip-autofocus!="true"]:first').focus();
76  
-				
77 71
 				// Optionally get the form attributes from embedded fields, see Form->formHtmlContent()
78 72
 				for(var overrideAttr in {'action':true,'method':true,'enctype':true,'name':true}) {
79 73
 					var el = this.find(':input[name='+ '_form_' + overrideAttr + ']');
@@ -110,7 +104,18 @@
110 104
 				this.changetracker('destroy');
111 105
 				this._super();
112 106
 			},
113  
-						
  107
+			onmatch: function() {
  108
+				this._super();
  109
+
  110
+				// focus input on first form element. Exclude elements which
  111
+				// specifically opt-out of this behaviour via "data-skip-autofocus".
  112
+				// This opt-out is useful if the first visible field is shown far down a scrollable area,
  113
+				// for example for the pagination input field after a long GridField listing.
  114
+				this.find(':input:not(:submit)[data-skip-autofocus!="true"]').filter(':visible:first').focus();
  115
+			},
  116
+			onunmatch: function() {
  117
+				this._super();
  118
+			},
114 119
 			redraw: function() {
115 120
 				if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
116 121
 				

0 notes on commit 2fa835a

Please sign in to comment.
Something went wrong with that request. Please try again.