File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -261,8 +261,22 @@ function pjax(options) {
261
261
window . history . replaceState ( pjax . state , container . title , container . url )
262
262
}
263
263
264
+ // Clear out any focused controls before inserting new page contents.
265
+ document . activeElement . blur ( )
266
+
264
267
if ( container . title ) document . title = container . title
265
268
context . html ( container . contents )
269
+
270
+ // FF bug: Won't autofocus fields that are inserted via JS.
271
+ // This behavior is incorrect. So if theres no current focus, autofocus
272
+ // the last field.
273
+ //
274
+ // http://www.w3.org/html/wg/drafts/html/master/forms.html
275
+ var autofocusEl = context . find ( 'input[autofocus], textarea[autofocus]' ) . last ( ) [ 0 ]
276
+ if ( autofocusEl && document . activeElement !== autofocusEl ) {
277
+ autofocusEl . focus ( ) ;
278
+ }
279
+
266
280
executeScriptTags ( container . scripts )
267
281
268
282
// Scroll to top by default
You can’t perform that action at this time.
0 commit comments