File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
src/tpl/defaultTheme/frontend Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 233233
234234 function keepFocusOnBackwardForward ( ) {
235235 if ( window . onpageshow === undefined || ! document . querySelector ) return ;
236- document . body . querySelector ( '.item-list' ) . addEventListener ( 'focusin' , function ( e ) {
237- lastFocused = e . target ;
238- } ) ;
236+
237+ function onFocus ( e ) {
238+ var link = e . target ;
239+ while ( link && ! ( link instanceof HTMLAnchorElement ) ) {
240+ link = link . parentElement ;
241+ }
242+ if ( ! link || link === lastFocused ) return ;
243+ lastFocused = link ;
244+ }
245+
246+ var itemList = document . body . querySelector ( '.item-list' ) ;
247+ itemList . addEventListener ( 'focusin' , onFocus ) ;
248+ itemList . addEventListener ( 'click' , onFocus ) ;
239249 window . addEventListener ( 'pageshow' , function ( ) {
240250 if ( lastFocused && lastFocused !== document . activeElement ) {
241251 lastFocused . focus ( ) ;
You can’t perform that action at this time.
0 commit comments