Repository navigation
[slider] Fix touch track tap not firing onValueCommitted - #5779
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,224.33 ms +84.45 ms(+7.4%) | Renders: 76 (+0) | Paint: 2,008.97 ms +107.45 ms(+5.7%) No significant changes — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
PR reviewThis fixes #5772. I confirmed it by running an independent set of regression tests, written against the bug before this PR existed, on this branch's source: a touch tap commits once on both controlled and uncontrolled sliders, and the tap test added here fails on the base commit. Nothing is merge-blocking. The findings are one narrow stale-state path, one test that passes without the fix, and an undisclosed behavior change that looks like an improvement but has no test. The claim that this regressed in v1.6.0 via #4937 checks out: that commit introduced both the pointer-path track press and the reset that clears the recorded value, and it first appears in the v1.6.0 tag. Bugs (1)1. 🟡 The gesture flag is never cleared when a gesture is cancelledLocation: pressedValuesRef.current = null;
currentInteractionValueRef.current = null;
pointerGestureRef.current = false;
Failure scenario: a drag interrupted by a system gesture, then a press on which the pointer handler returns early, does nothing at all: the thumb does not move. I demonstrated it by forcing a Fix: clear the flag wherever a cancel is handled, which is worth doing together with #5637. Setting it only for Tests (3)1. 🟡 The pointercancel test passes without the source changeLocation: I ran both new tests against the base commit. The tap test fails, correctly. This one passes, because on base the Failure scenario: a future refactor could delete the fix and keep this test green, leaving only the first test as real coverage. Fix: reword it as a guard for the touch listeners, or assert a case base fails, such as a controlled slider tapped, then 2. ℹ️ The new tests never exercise the pointer path they describeLocation: The file's Failure scenario: anyone moving these tests next to the code they cover, in the control's own test file, loses that stub. Pointer capture then runs, and Fix: leave them here, or stub the three capture methods if they move. 3. ℹ️ A touch tap on the thumb no longer applies a value, with nothing pinning itLocation: Skipping the touch press setup also skips the touch path's unconditional Failure scenario: with Fix: add a short test pinning that a touch tap on the thumb leaves the value unchanged, and mention the change in the description. VerdictApprove after nits - the fix is correct and verified against independent tests, and every finding is a narrow edge case or test-quality point rather than a defect in the shipped path. 🤖 Review generated with Claude Code |
ed9f377 to
fffd7b5
Compare
|
@claude review |
PR reviewThe fix itself is sound: gating Bugs (2)1. 🟠 Stylus taps keep missing
|
Fixes #5772
This PR makes a touch tap on the slider track fire
onValueCommitted, just like a mouse click. Controlled and uncontrolled sliders were both affected. This regressed in v1.6.0 (#4937).A touch fires
pointerdownfollowed by the compatibilitytouchstart, and both ran the press-start logic. The pointer handler set the value and remembered it as the value to commit. The touch handler then calledstartPressing(), which cleared it. Re-applying the same value is a no-op, so nothing was remembered and release skipped the commit. A drag only worked because the next move remembered a new value.Changes
pointerdownhas started a gesture,touchstartno longer restarts it or sets the value again. Pen is included because Apple Pencil also fires a compatibilitytouchstart. The touch handler still attaches its touch listeners: withouttouch-action: none, Chrome cancels the pointer partway through a drag, and those listeners keep the drag going untiltouchendcommits it.pointerdown, and cleared by thetouchstartthat reads it and when listeners stop. A cancelled gesture, including a pen gesture with notouchstart, can't leave it set for the next press.step={3}).pointerdown,touchstart,pointerup,touchend) for touch and pen. Others cover the drag continuing afterpointercancel, a touch press after a cancelled mouse, pen, or touch gesture, and a touch or pen tap on the thumb.