Skip to content

fix: keep preventDefault working in the legacy mouse/touch bridge - #890

Merged
tomkp merged 3 commits into
tomkp:masterfrom
akx:fix-styled
Oct 26, 2026
Merged

tomkp merged 3 commits into
tomkp:masterfrom
akx:fix-styled

Conversation

@akx

@akx akx commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

I noticed the "styled" example wasn't working - looks like it probably broke with #879.

akx and others added 2 commits June 9, 2026 12:43
Spreading a React SyntheticEvent only copies own properties,
so preventDefault and stopPropagation were dropped.

The synthetic events might not have real pointer IDs,
so guard against `setPointerCapture` throwing.
The legacy onMouseDown/onTouchStart bridge gave drags a made-up pointerId
(1 for mouse, touch.identifier for touch). Real pointer events rarely
match it, so those drags never moved and, now that preventDefault works,
never ended either, leaving the divider stuck in its dragging state.

- Bridged drags start without a pointerId and adopt the first primary
  pointer that follows.
- Ignore a second start while a drag is in progress. Dividers that spread
  {...props} get both onPointerDown and onTouchStart, so a finger fired
  pointerdown then touchstart and the second start hijacked the drag.
@tomkp

tomkp commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks for this, and sorry for the slow response! The preventDefault fix is right: the legacy handlers were throwing on every mousedown/touchstart.

While testing I found two more problems in the same bridge, so I've pushed a commit on top of yours:

  • The bridge made up a pointerId (1 for mouse, touch.identifier for touch), and the real pointer events didn't match it. With preventDefault fixed, a touch-only legacy divider (and a mouse one, if the browser's mouse pointerId isn't 1) would now start a drag that never moves or ends, leaving the divider stuck in its dragging state. Bridged drags now start without a pointerId and adopt the first primary pointer that follows.
  • Dividers that spread {...props}, as the README shows, get both onPointerDown and onTouchStart. A finger fires pointerdown then touchstart, and the second start hijacked the drag. A start is now ignored while a drag is already in progress.

I dropped the try/catch around setPointerCapture, since it's now only called with a real pointerId. Tests for both cases are included. Shout if anything looks off; otherwise I'll merge this along with #888 and #889.

@tomkp
tomkp merged commit 53674ae into tomkp:master Oct 26, 2026
1 check passed
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.

2 participants