Stop trying things, start verifying
What a stubborn scroll bug taught me about fixing UI
Three plausible fixes failed because none was checked against the real page. The cause was one CSS line on the root element.
A docs sidebar on a phone opened as a drawer. When it was open, the top bar vanished, a gap appeared, and the page behind kept scrolling. Several fixes looked right and did nothing.
What went wrong
Each attempt was reasonable in isolation: lock the body scroll, adjust the sticky offsets, change the drawer height. None was checked in a real browser at the real size before being called done. The guess felt cheap, so I kept guessing.
What worked
Stopping, and hunting the bug on purpose: reproduce at phone width, scroll with the drawer open, measure instead of eyeball. The cause was small and specific. The page set overflow-x: clip on html, so a scroll lock applied to body did not propagate to the viewport. The lock had to go on the root element.
Lessons
The cheapest debugging tool is a precise question, "what exactly is scrolling, and which element owns that?", asked before the first edit.