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 7272 } catch ( err ) {
7373 }
7474
75+ var lastFocused ;
76+
7577 function enableFilter ( ) {
7678 if ( ! document . querySelector ) {
7779 var filter = document . getElementById && document . getElementById ( 'panel-filter' ) ;
229231 }
230232 }
231233
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+
232247 function focusChildOnNavUp ( ) {
233248 if ( ! document . querySelector ) return ;
234249
272287 if ( text !== prevChildName ) continue ;
273288 var elLink = item . querySelector ( selectorLink ) ;
274289 if ( elLink ) {
290+ lastFocused = elLink ;
275291 elLink . focus ( ) ;
276292 elLink . scrollIntoView ( { block : 'center' } ) ;
277293 }
13161332 }
13171333
13181334 enableFilter ( ) ;
1335+ keepFocusOnBackwardForward ( ) ;
13191336 focusChildOnNavUp ( ) ;
13201337 enableKeyboardNavigate ( ) ;
13211338 enhanceUpload ( ) ;
You can’t perform that action at this time.
0 commit comments