File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
packages/site-kit/src/lib Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ It appears when the user clicks on the `Search` component or presses the corresp
2626 let search: any = $state (null );
2727 let recent_searches: any [] = $state ([]);
2828
29+ let last_scroll_position: number | null = null ;
30+
2931 let worker: Worker ;
3032 let ready = $state (false );
3133
@@ -68,9 +70,9 @@ It appears when the user clicks on the `Search` component or presses the corresp
6870 async function close() {
6971 if ($searching ) {
7072 $searching = false ;
71- const scroll = - parseInt (document .body .style .top || ' 0' );
73+ const scroll = last_scroll_position || 0 ;
74+ last_scroll_position = null ;
7275 document .body .style .position = ' ' ;
73- document .body .style .top = ' ' ;
7476 document .body .tabIndex = - 1 ;
7577 document .body .focus ();
7678 document .body .removeAttribute (' tabindex' );
@@ -108,10 +110,7 @@ It appears when the user clicks on the `Search` component or presses the corresp
108110
109111 $effect (() => {
110112 if ($searching ) {
111- document .body .style .top = ` -${window .scrollY }px ` ;
112- document .body .style .position = ' fixed' ;
113-
114- $overlay_open = true ;
113+ last_scroll_position = window .scrollY ;
115114 }
116115 });
117116 </script >
Original file line number Diff line number Diff line change @@ -14,8 +14,10 @@ overlay_open.subscribe((value) => {
1414 if ( value ) {
1515 // Disable root from scrolling
1616 document . documentElement . style . overflow = 'hidden' ;
17+ document . documentElement . style . scrollbarGutter = 'stable' ;
1718 } else {
1819 // Enable root to scroll
1920 document . documentElement . style . overflow = '' ;
21+ document . documentElement . style . scrollbarGutter = '' ;
2022 }
2123} ) ;
You can’t perform that action at this time.
0 commit comments