Skip to content

Keep the timeline in place when a mobile header drawer closes - #6257

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-timeline-scroll-on-drawer-close-thr_ch5sb54cg8
Oct 25, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-timeline-scroll-on-drawer-close-thr_ch5sb54cg8

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

On compact viewports, AppPageHeader scrolls the page to the top when its background is tapped (#4742). The thread actions menu renders its drawer through a portal, but React bubbles synthetic events through the component tree, not the DOM tree. A tap on the drawer's backdrop (or its grab handle) therefore reached the header's onClick. The target was a plain div, so it passed the interactive-element filter, and closing the drawer smooth-scrolled the timeline to the top. #4742 listed this as a deferred follow-up ("Ignore portaled menu-backdrop clicks in the header handler").

What changed

  • apps/app/src/components/layout/AppPageHeader.tsx: the compact tap-to-top handler ignores clicks whose target is outside the header's DOM (!event.currentTarget.contains(event.target)). Taps on the header itself behave as before.
  • apps/app/src/components/layout/AppPageHeader.test.tsx: covers a header tap (scrolls to top) and a click from a portaled child (does not).

How you verified

  • Reproduced on an Android emulator (Pixel 9, Chrome) against the live app with a scroll-write probe. Tapping the backdrop logged viewport.scrollTo({ top: 0, behavior: "smooth" }) from the PAGE_SCROLL_TO_TOP_EVENT handler, called from React's click dispatch.
  • Headless Chrome at 390×844: open the drawer at scrollTop 6000, then click the backdrop. Main moves the timeline; this branch stays at 6000. Re-checked on a pnpm start:worktree server for this branch: the backdrop keeps the position, and the header "Scroll to top" button still scrolls.
  • The new test's portal case fails without the fix and passes with it.
  • pnpm exec turbo run typecheck --filter=@bb/app and pnpm exec turbo run lint --filter=@bb/app pass.

AGENT GENERATED

🤖 Generated with Claude Code

The compact header's tap-to-scroll-to-top handler received clicks from
portaled overlays rendered by header content, because React bubbles
synthetic events through the component tree. Tapping the thread actions
drawer's backdrop therefore scrolled the timeline to the top. Ignore
clicks whose target is outside the header's DOM.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 37e51c1 into main Oct 25, 2026
30 checks passed
@ymichael
ymichael deleted the bb/fix-timeline-scroll-on-drawer-close-thr_ch5sb54cg8 branch October 25, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant