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

  • A fix you have not seen work is a hypothesis. Screenshot it, at the width where the bug lives.
  • Separate finding from fixing. One pass to reproduce and name the cause, a second to change code. Handing the hunt to a fresh pair of eyes (an agent or a colleague) stops the original guess from anchoring everything.
  • Keyboard and focus are part of the bug. The same drawer let Tab escape into the page behind it, and Escape returned focus to a heading anchor. A visual pass alone would have shipped both.
  • Make the check permanent. The layout audit that now runs in CI checks horizontal overflow at five widths, so this class of regression has a tripwire.
  • The cheapest debugging tool is a precise question, "what exactly is scrolling, and which element owns that?", asked before the first edit.

    Tagged: debugging, ui, testing, process

    Area: Thoughts

    Related notes

    עברית