File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,18 @@ function getElAndScroll() {
20
20
const element = document . getElementById ( hashFragment ) ;
21
21
if ( element !== null ) {
22
22
scrollFunction ( element ) ;
23
+
24
+ // update focus to where the page is scrolled to
25
+ // unfortunately this doesn't work in safari (desktop and iOS) when blur() is called
26
+ let originalTabIndex = element . getAttribute ( 'tabindex' ) ;
27
+ if ( originalTabIndex === null ) element . setAttribute ( 'tabindex' , - 1 ) ;
28
+ element . focus ( { preventScroll : true } ) ;
29
+ // for some reason calling blur() in safari resets the focus region to where it was previously,
30
+ // if blur() is not called it works in safari, but then are stuck with default focus styles
31
+ // on an element that otherwise might never had focus styles applied, so not an option
32
+ element . blur ( ) ;
33
+ if ( originalTabIndex === null ) element . removeAttribute ( 'tabindex' ) ;
34
+
23
35
reset ( ) ;
24
36
return true ;
25
37
}
You can’t perform that action at this time.
0 commit comments