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 233
233
234
234
function keepFocusOnBackwardForward ( ) {
235
235
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 ) ;
239
249
window . addEventListener ( 'pageshow' , function ( ) {
240
250
if ( lastFocused && lastFocused !== document . activeElement ) {
241
251
lastFocused . focus ( ) ;
You can’t perform that action at this time.
0 commit comments