Skip to content

Keep sidebar and right panel swipes tracking when the touched node remounts - #7600

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-sidebar-swipe-rendering-bug-thr_caecq3dfi8
Nov 16, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-sidebar-swipe-rendering-bug-thr_caecq3dfi8

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

On compact screens, swiping the sidebar or the right panel sometimes left it stuck partway until the next swipe. This happened when the timeline re-rendered during the swipe. Touch events always go to the element the touch started on, even after it has been removed from the page, and a removed element no longer passes them on to window. The swipe code listened for the rest of the gesture (touchmove, touchend, and the pointer equivalents) only on window. So when a re-render remounted the touched element, the swipe stopped receiving events and never finished. recoverInterruptedMobileSwipe reset it on the next touch, which is why another swipe got it unstuck. #6469 fixed the same problem for sidebar row drags.

What changed

  • gesture-dom.ts: a new listenToGesture(origin, type, listener, options) listens on both window and the element the gesture started on, and calls the listener once even when the same event reaches both.
  • sidebar.tsx: the swipe that opens the sidebar uses it for both touch and pointer input.
  • use-horizontal-dismiss-drag.ts: uses it for both touch and pointer input. This covers dragging the sidebar drawer closed and both right-panel drags (open and close).

How you verified

  • New tests: sidebar.test.tsx covers a touch and a pointer swipe whose touched element remounts mid-drag. CompactSecondaryPanelShelf.test.tsx covers opening and closing the right panel the same way. All four fail without the source change and pass with it.
  • pnpm exec turbo run test --filter=@bb/app -- src/components/ui src/components/secondary-panel src/components/sidebar passed: 1379 tests in 125 files.
  • pnpm exec turbo run typecheck lint --filter=@bb/app passed.
  • Manual check on a pnpm start:worktree build, comparing it with main's app bundle on the same server and data. I used headless Chrome as a touch phone and sent real touches over the Chrome DevTools Protocol. Partway through each swipe I swapped the touched element for a copy, which is what a remount does. Results after lifting the finger:
Case Sizes main This branch
Swipe right to open the sidebar 390×844, 360×780, 744×1133 stuck 110px across opens fully
Swipe left to open the right panel same three stuck at −90px, panel stays closed opens fully
Drag a sidebar row left to close the sidebar 390×844 stuck 255px across closes
Drag right inside the right panel to close it 390×844 stays open with a −270px offset on the page behind closes
Normal swipe, nothing remounted (control) 390×844 opens fully —
  • Not tested: a physical device, iOS Simulator Safari, and the native mobile shell.

AGENT GENERATED

🤖 Generated with Claude Code

…mounts

Touch events keep targeting the node where the touch started. When the
timeline re-renders and replaces that node mid-swipe, the remaining
touchmove/touchend events go to a detached node and never bubble to
window, where the sidebar swipe and useHorizontalDismissDrag listened.
The page stayed partly translated until the next touch recovered it.

Listen on both window and the gesture's origin node through a shared
listenToGesture helper, deduplicating events that reach both. This covers
the sidebar open swipe, the drawer close drag, and both right panel shelf
drags. #6469 fixed the same class for sidebar row drags.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit f266dc1 into main Nov 16, 2026
31 checks passed
@ymichael
ymichael deleted the bb/fix-sidebar-swipe-rendering-bug-thr_caecq3dfi8 branch November 16, 2026 18:48
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