File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/tpl/defaultTheme/frontend Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 72
72
} catch ( err ) {
73
73
}
74
74
75
+ var lastFocused ;
76
+
75
77
function enableFilter ( ) {
76
78
if ( ! document . querySelector ) {
77
79
var filter = document . getElementById && document . getElementById ( 'panel-filter' ) ;
229
231
}
230
232
}
231
233
234
+ function keepFocusOnBackwardForward ( ) {
235
+ if ( window . onpageshow === undefined || ! document . querySelector ) return ;
236
+ document . body . querySelector ( '.item-list' ) . addEventListener ( 'focusin' , function ( e ) {
237
+ lastFocused = e . target ;
238
+ } ) ;
239
+ window . addEventListener ( 'pageshow' , function ( ) {
240
+ if ( lastFocused && lastFocused !== document . activeElement ) {
241
+ lastFocused . focus ( ) ;
242
+ lastFocused . scrollIntoView ( { block : 'center' } ) ;
243
+ }
244
+ } ) ;
245
+ }
246
+
232
247
function focusChildOnNavUp ( ) {
233
248
if ( ! document . querySelector ) return ;
234
249
272
287
if ( text !== prevChildName ) continue ;
273
288
var elLink = item . querySelector ( selectorLink ) ;
274
289
if ( elLink ) {
290
+ lastFocused = elLink ;
275
291
elLink . focus ( ) ;
276
292
elLink . scrollIntoView ( { block : 'center' } ) ;
277
293
}
1316
1332
}
1317
1333
1318
1334
enableFilter ( ) ;
1335
+ keepFocusOnBackwardForward ( ) ;
1319
1336
focusChildOnNavUp ( ) ;
1320
1337
enableKeyboardNavigate ( ) ;
1321
1338
enhanceUpload ( ) ;
You can’t perform that action at this time.
0 commit comments