Skip to content

Commit dc57bac

Browse files
guygrigsbyclaude
andcommitted
Drawer: revert body position:fixed scroll lock.
The aggressive iOS variant (position: fixed + top offset) broke inner scrolling — the chub results stopped scrolling at all. Back to the simpler `overflow: hidden` body lock, which lets nested overflow-y-auto regions scroll normally. Leaves the bottom-nav-bouncing fix incomplete on iOS for now; overscroll-behavior: contain on the results list is doing what it can. Will revisit with a different angle if it keeps reproducing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 138018e commit dc57bac

1 file changed

Lines changed: 8 additions & 35 deletions

File tree

web/src/components/Drawer.svelte

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,17 @@
2222
2323
let { open, onClose, ...rest }: Props = $props()
2424
25-
// iOS-strength body scroll lock while the drawer is open. The
26-
// weaker `overflow: hidden` version still let iOS interpret touch-
27-
// scroll attempts as "page wants to scroll", which collapses the
28-
// address bar and re-flows the visual viewport — visibly bouncing
29-
// the drawer's bottom tab bar as the chub results list reaches its
30-
// scroll edge. Pinning body to `position: fixed` actually anchors
31-
// the layout so the address bar stops collapsing/expanding on
32-
// touch. We capture the current scrollY into `top: -<y>px` and
33-
// restore both on close, so the user lands exactly where they
34-
// started behind the drawer.
25+
// Lock body scroll while the drawer is open. Prevents iOS Safari
26+
// from rubber-banding the document when an inner scroll hits its
27+
// edge. The earlier `position: fixed` variant broke inner scrolling
28+
// entirely; `overflow: hidden` is the minimum that still lets the
29+
// drawer's overflow-y-auto regions scroll normally.
3530
$effect(() => {
3631
if (typeof document === 'undefined') return
3732
if (!open) return
38-
const body = document.body
39-
const prev = {
40-
position: body.style.position,
41-
top: body.style.top,
42-
left: body.style.left,
43-
right: body.style.right,
44-
width: body.style.width,
45-
overflow: body.style.overflow,
46-
}
47-
const scrollY = window.scrollY
48-
body.style.position = 'fixed'
49-
body.style.top = `-${scrollY}px`
50-
body.style.left = '0'
51-
body.style.right = '0'
52-
body.style.width = '100%'
53-
body.style.overflow = 'hidden'
54-
return () => {
55-
body.style.position = prev.position
56-
body.style.top = prev.top
57-
body.style.left = prev.left
58-
body.style.right = prev.right
59-
body.style.width = prev.width
60-
body.style.overflow = prev.overflow
61-
window.scrollTo(0, scrollY)
62-
}
33+
const prev = document.body.style.overflow
34+
document.body.style.overflow = 'hidden'
35+
return () => { document.body.style.overflow = prev }
6336
})
6437
</script>
6538

0 commit comments

Comments
 (0)