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
26
26
let search: any = $state (null );
27
27
let recent_searches: any [] = $state ([]);
28
28
29
+ let last_scroll_position: number | null = null ;
30
+
29
31
let worker: Worker ;
30
32
let ready = $state (false );
31
33
@@ -68,9 +70,9 @@ It appears when the user clicks on the `Search` component or presses the corresp
68
70
async function close() {
69
71
if ($searching ) {
70
72
$searching = false ;
71
- const scroll = - parseInt (document .body .style .top || ' 0' );
73
+ const scroll = last_scroll_position || 0 ;
74
+ last_scroll_position = null ;
72
75
document .body .style .position = ' ' ;
73
- document .body .style .top = ' ' ;
74
76
document .body .tabIndex = - 1 ;
75
77
document .body .focus ();
76
78
document .body .removeAttribute (' tabindex' );
@@ -108,10 +110,7 @@ It appears when the user clicks on the `Search` component or presses the corresp
108
110
109
111
$effect (() => {
110
112
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 ;
115
114
}
116
115
});
117
116
</script >
Original file line number Diff line number Diff line change @@ -14,8 +14,10 @@ overlay_open.subscribe((value) => {
14
14
if ( value ) {
15
15
// Disable root from scrolling
16
16
document . documentElement . style . overflow = 'hidden' ;
17
+ document . documentElement . style . scrollbarGutter = 'stable' ;
17
18
} else {
18
19
// Enable root to scroll
19
20
document . documentElement . style . overflow = '' ;
21
+ document . documentElement . style . scrollbarGutter = '' ;
20
22
}
21
23
} ) ;
You can’t perform that action at this time.
0 commit comments