Repository navigation
fix(Slider): two coincident range thumbs can be dragged apart - #8151
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Approval waits on an engineering owner's decision: no current spec says which thumb a pointer press should take when both range thumbs share a value, and this PR picks by the side of the press. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner; writing the chosen rule into the Slider spec keeps it from being re-decided. Two issues also need fixing, the first in whatever form the chosen rule implies:
- With both thumbs on one value inside the range, a press a few pixels left of their centre that is then dragged toward the maximum no longer moves anything, though it works on
main(Slider.tsxline 782). - After a press on the shared value hands the drag to the other thumb, the first thumb's value tooltip stays open once the drag ends, with mouse and with touch (
Slider.tsxline 832).
[Automated review]
| if (newVal === values[0]) { | ||
| coincidentDragRef.current = values[0]; | ||
| } else { | ||
| thumbIndex = newVal > values[0] ? 1 : 0; |
There was a problem hiding this comment.
With coincident values, newVal for a direct press is the pointer position, so a press more than half a step left of the thumbs' centre commits to the lower thumb here, before any movement. Dragging toward the maximum then leaves both thumbs stuck: with both at 80, main ends at [80, 99] and this branch at [80, 80] (Chromium, mouse and touch). Parking any direct press on coincident thumbs and choosing by the first movement's direction would keep that drag working; which rule applies is the open owner question.
There was a problem hiding this comment.
A drag that starts on two coincident thumbs should never stick, whichever side of their centre the finger lands. Fixed in 8416061: a press on the thumbs themselves now moves nothing until the pointer moves, and the direction of that first movement from the press picks the thumb. With both at 80, a press at 79 dragged up now ends at [80, 100], as on main. A track press beside them still picks the thumb on its side. The description names which thumb a press takes as the owner decision, and a new test covers both directions.
| setDraggingThumb(thumbIndex); | ||
| const thumbs = | ||
| trackRef.current?.querySelectorAll<HTMLElement>('[role="slider"]'); | ||
| thumbs?.[thumbIndex]?.focus(); |
There was a problem hiding this comment.
Focus moves here while the abandoned thumb's Tooltip is still forced open (isOpen={draggingThumb === thumbIndex ? true : undefined}). Its focusout hide is skipped while isOpen === true, and the later switch to undefined hides nothing, so that thumb's value tooltip stays open after release, with mouse and with touch. Giving the non-dragged thumb isOpen={false} during a drag (for example draggingThumb === null ? undefined : draggingThumb === thumbIndex) would close it.
There was a problem hiding this comment.
A tooltip that stays open after the drag ends shows a value nobody is touching. Fixed in 8416061: while a drag runs, the other thumb's tooltip is controlled closed (isOpen={draggingThumb === null ? undefined : draggingThumb === thumbIndex}), and both go back to their own triggers when the drag ends. A new test fails on the previous head and passes now.
PR Analysis Report
Modified ComponentsSlider (@astryxdesign/core)
Component Size
Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included. Bundle Size SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | View full report |
<!-- template: bug-fix.md --> Siblings on the same pointer handlers: #8151 (coincident range thumbs) and #7516 (pointer selection of an off-grid max). Whichever lands later is rebased. ## User impact On a touch screen, a second finger that touches a Slider during a drag (a palm, a resting thumb) takes the drag over. The value jumps to that finger. When it lifts, `onChangeEnd` commits a value the user never chose, and the first finger stops moving the slider. Now the drag belongs to the finger that started it, and two fingers can still drag two sliders. ## Problem and solution fit 1. **Why it happens.** The handlers ignore `pointerId`: any `pointerdown` starts a drag, any `pointermove` drives it, and any `pointerup` ends it. 2. **Why it harms the task.** The value no longer follows the hand that moves it. 3. **Why it matters.** Owners commit on `onChangeEnd`, so a stray touch commits a wrong value. The slider ignores every other pointer until the drag's own pointer lifts or is cancelled. A capture lost without an up also ends the drag. Otherwise a drag left open would block every later press. ## Expected behavior and authority - `component:Slider` FR5: `onChangeEnd` fires once, when the drag is released or cancelled. - Touch reference: a UIKit control tracks one touch, because `UIView.isMultipleTouchEnabled` defaults to `false` ([Apple](https://developer.apple.com/documentation/uikit/uiview/ismultipletouchenabled)). ## Smallest restoration The change is in `Slider.tsx` only. A ref holds the drag's `pointerId`, and a `lostpointercapture` listener ends the drag. There is no new prop. ## Evidence Real touch in Chromium (phone emulation, two touch points). Finger A grabs the thumb at 50, and finger B lands on the track at 10 %: | Step | `main` | This branch | | --- | --- | --- | | A drags +30 px | 61 | 61 | | B lands | **7** | 61 | | A drags +40 px, B moves | **9** | 64 | | B lifts | **`onChangeEnd(9)`** | nothing | | A drags +60 px, lifts | **stays 9** | 71, `onChangeEnd(71)` | - Unchanged paths: two fingers dragging two sliders, and every existing single-pointer test. - Regression test: "one pointer per drag" in `Slider.test.tsx`. Its second-finger and lost-capture cases fail on `main`. ## Scope - [x] One defect is restored. - [x] Separable contradictory or unsettled tagalongs were removed or split. - [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label. - [x] Public text and artifacts contain no internal Meta context. ## Testing - `pnpm exec vitest run --project ui packages/core/src/Slider`: 3 files, 98 tests pass. With `main`'s `Slider.tsx`, 2 of the 3 new cases fail. - `pnpm -F @astryxdesign/core typecheck`, eslint and prettier on the touched files, and the pre-commit checks: pass. - Chromium, phone viewport, two touch points: the table above.
5b96db3 to
0dbba4f
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision: no current spec says which thumb a pointer press takes when both range thumbs share a value, and this PR now picks by the side of a track press and by the first movement of a press on the thumbs. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), and the chosen rule belongs in the Slider spec. Two drags that work on main also stick on this branch:
- With both thumbs at 80, a press whose first step goes toward the minimum and then drags to 99 ends at [80, 80] instead of [80, 99] (
Slider.tsxlines 835-842); the fix depends on the rule the owner chooses. - With both thumbs on a labelled mark, a press on the label right of the mark dragged toward the minimum moves the end thumb right and then sticks, because the parked value is the mark's rather than the pointer's (
Slider.tsxline 792).
[Automated review]
| // drag to the thumb that can travel that way, with its focus and | ||
| // pressed paint. | ||
| coincidentDragRef.current = null; | ||
| const thumbIndex = newVal > pressValue ? 1 : 0; |
There was a problem hiding this comment.
The first value that differs from the press decides the thumb for the rest of the drag. A first step the other way (a touch contact drifting at press, say) then sticks a drag toward the maximum that works on main: with both at 80, a press, one step toward the minimum and a drag to 99 end at [80, 80] instead of [80, 99]. Whether that is acceptable is part of the open owner decision; otherwise, handing the drag to the other thumb once the dragged one is held against it and the pointer moves past it would avoid it.
There was a problem hiding this comment.
Fixed in 8846cff: a drag that began on coincident thumbs now hands itself to the other thumb once the pointer passes it, with both values set in one update. With both at 80, a first step to 79 and a drag on to 99 end at [80, 99], as on main. The new case fails on the previous head; the earlier case that kept the drag on its first thumb back past the other now expects the hand-off.
| pressedThumbIndex >= 0 ? pressedThumbIndex : getClosestThumb(newVal); | ||
| const parks = | ||
| isCoincident && (pressedThumbIndex >= 0 || newVal === values[0]); | ||
| coincidentDragRef.current = parks ? newVal : null; |
There was a problem hiding this comment.
For a mark press newVal is the mark's value, so a press on a wide label away from the mark parks the mark's value and the first pointer value already differs from it. With both at 50 on a "50%" label, a press right of the mark dragged left moves the end thumb to 52 and then sticks at [50, 50]; on main it reaches [20, 50]. Parking getValueFromPosition(e.clientX, e.clientY) instead would compare the movement against the press itself.
There was a problem hiding this comment.
Fixed in 8846cff: the parked press now uses the pointer's own value, not the mark's, so the first movement is read from where the press landed. With both at 50, a press right of the "50%" mark dragged left reaches [20, 50], as on main. The new case fails on the previous head.
…fari) Recordings of the iOS 26.2 simulator (iPhone 17 Pro) in Mobile Safari, cropped to the page; the gray dot is the finger, drawn by the test page. main against each pull request: meta#8151 coincident range thumbs, meta#8168 translate travel, meta#8190 the touch presentation and its held-thumb fix.
…eta#8190 24030a1) iOS 26.2 simulator, Mobile Safari. meta#8190's clips are re-recorded on the build whose lifted thumb grows around its center (the earlier clips showed it 5.5 px off the track); the catch is now side by side with the same flick alone (77 against 63); the past-the-end clip runs through the lift; the tap is held 0.3 s. meta#8151's tooltip clip hides the row label so the tooltips read clearly, and its coincident clip names the off-center press precisely.
8f0ab9e to
93994b0
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision: no current spec says which thumb a pointer press takes when both range thumbs share a value, and this PR picks by the side of a track press and by the first movement of a press on the thumbs. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), and the chosen rule belongs in the Slider spec. Two drags that work on main also stick on this branch and need fixing:
- With both thumbs at 80, a press whose first step goes toward the minimum and then drags to 99 ends at [80, 80] instead of [80, 99] (
Slider.tsxlines 874-892); the fix depends on the rule chosen. - With both thumbs on a labelled mark, a press on the label right of the mark dragged toward the minimum moves the end thumb right and then sticks, because the parked value is the mark's rather than the pointer's (
Slider.tsxline 818).
[Automated review]
There was a problem hiding this comment.
Approval waits on an engineering owner's decision: no current spec says which thumb a pointer press takes when both range thumbs share a value, and this PR picks by the side of a track press and by the first movement of a press on the thumbs, then hands the drag to the other thumb whenever the pointer passes it. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), and the chosen rule belongs in the Slider spec. The two drags that stuck on the previous revision now end as on main, so nothing else needs to change if the rule is adopted as implemented; one consequence to weigh is that a drag that began on coincident thumbs and comes back past their value now moves the other thumb (both at 80, a drag to 95 and back to 50 ends at [50, 80], where main ends at [80, 80]).
[Automated review]
Only one of two thumbs on the same value can travel toward where the pointer goes, so a press on the track beside them picks the thumb on its side, and a press on the thumbs themselves waits for the pointer to move: the direction of that first movement picks the thumb, which takes the drag's focus, pressed paint and value tooltip. Once the pointer passes the other thumb, the dragged thumb stops against it and the other takes the drag, so a first step that drifts the wrong way never sticks it. Before, two thumbs at the maximum could not be dragged down, and a track press above two coincident thumbs moved neither.
8846cff to
f2f46e6
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision: no current spec says which thumb a pointer press takes when both range thumbs share a value, and this PR picks by the side of a track press and by the first movement of a press on the thumbs, then hands the drag to the other thumb whenever the pointer passes it. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), and the chosen rule belongs in the Slider spec. Nothing else needs to change if the rule is adopted as implemented; the consequences to weigh are that a drag that began on coincident thumbs and comes back past their value moves the other thumb (both at 80, a drag to 95 and back to 50 ends at [50, 80], where main ends at [80, 80]), and that on a narrow track a press left of the thumbs' centre that moves right first moves the lower thumb to the pointer.
[Automated review]
… both share a value (FR6) FR6 states the rule this change implements: when both thumbs of a range share a value, a pointer press takes the thumb that can travel toward the pointer, by the side of a track press or the direction of the first movement after a press on the thumbs. It also states the consequence: a drag that began on the shared thumbs and comes back past their value moves the other thumb. A verification row names the focused tests.
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on FR6, the rule this pull request adds to the Slider spec for which thumb a pointer press takes when both range thumbs share a value; an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Before that approval, please make FR6 and the code agree:
- FR6 limits the hand-off to a drag that began on the thumbs, but the code also hands over a drag that began with a track press beside them (both at 50, press the track at 30 and drag to 80:
[50, 80], wheremaingives[50, 50]), and no test covers it, so either reword FR6 and add that case, or limit the hand-off to presses on the thumbs. - FR6's basis reads "Current source and focused tests" although
mainbehaves otherwise, and the record's compatibility section still names only the RTL arrow-key fix as a behavior change, so give FR6 the owner's decision as its basis and list it there.
[Automated review]
| coincidentDragRef.current = parks | ||
| ? getValueFromPosition(e.clientX, e.clientY) | ||
| : null; | ||
| coincidentOriginRef.current = isCoincident; |
There was a problem hiding this comment.
This marks every drag that starts while the values are equal as coincident-origin, a track press beside the thumbs included, so that drag hands over too: both at 50, a track press at 30 dragged to 80 ends at [50, 80] (main: [50, 50]). FR6 describes the hand-off only for "a drag that began on the shared thumbs", and no case covers this path. Either set this only when the press parks, or widen FR6 and add the case.
| | FR3 | Filled range, tick marks, mark labels, and adjacent text value display are stable rendered parts without their own current Slider target. | Current source and public docs | Verified current asymmetry; not ratified as policy | | ||
| | FR4 | Label and status presentation continue to use Field and FieldStatus; value tooltips continue to use Tooltip. | Current source and focused tests | Verified composition boundary | | ||
| | FR5 | `onChangeEnd` fires once when an interaction ends — a pointer drag or track press is released or cancelled, or a keyboard step (arrow, Page, Home, End) completes — and carries the value the owner renders after its synchronous response to that interaction's `onChange` calls, including any clamp, snap, or rejection; it never carries a value Slider emitted that the owner did not render. A range reports both values the same way. | Maintainer decision (DEC-3) | Approved | | ||
| | FR6 | When both thumbs of a range share a value, a pointer press takes the thumb that can travel toward the pointer: a press on the track beside them takes the thumb on its side, and a press on the thumbs moves neither until the pointer moves, when the direction of that first movement picks the thumb, which takes the drag's focus, pressed state and value tooltip. A drag that began on the shared thumbs and comes back past their value moves the other thumb: the dragged thumb stops against it and the other follows the pointer, so with both at 80 a drag to 95 and back to 50 ends at [50, 80]. | Current source and focused tests | Accepted contract | |
There was a problem hiding this comment.
The hand-off sentence covers "a drag that began on the shared thumbs", but the code also hands over a drag that began with a track press beside them. The basis "Current source and focused tests" reads like observed behavior; main does otherwise, so the owner's decision is this row's basis, as DEC-3 is FR5's.
|
/approve-spec 6e1962b |
There was a problem hiding this comment.
Changes requested: FR6 is approved for this head and the coincident-thumb press rule behaves as it describes, but Slider.tsx also hands off a drag that starts with a track press beside coincident thumbs, which FR6 does not cover and no test exercises (both at 50, press the track at 20 and drag to 80: [50, 80], while the same drag from [30, 50] stops at [50, 50]). Either set coincidentOriginRef.current = parks and add a case for that drag, or widen FR6's hand-off sentence to drags that began while both thumbs shared a value, add the case, and have an engineering owner approve the new text. Please also reword the description's "no pointer path gets out of it": on main a track press below the thumbs and a drag on them toward the maximum already work.
[Automated review]
| coincidentDragRef.current = parks | ||
| ? getValueFromPosition(e.clientX, e.clientY) | ||
| : null; | ||
| coincidentOriginRef.current = isCoincident; |
There was a problem hiding this comment.
This marks every drag that starts while the values are equal as coincident-origin, a track press beside the thumbs included, so that drag hands over too: both at 50, a track press at 20 dragged to 80 ends at [50, 80], while the same drag from [30, 50] stops at [50, 50]. FR6 gives the hand-off only to a drag that began on the shared thumbs, and no case covers this path. Setting this to parks (plus a case) matches FR6 as approved; otherwise widen FR6 and add the case.
…thumbs stays on its thumb Both thumbs at 50, a track press at 20 takes the lower thumb there; the drag on toward 80 should stop it against the upper thumb at [50, 50], as the same drag from [30, 50] does. It fails today: the drag hands itself to the upper thumb and ends at [50, 80], though FR6 gives the hand-off only to a drag that began on the shared thumbs.
… to the other thumb A drag was marked as starting from coincident thumbs whenever the two values were equal at the press, so one that began with a track press beside them handed itself over too: both at 50, a press at 20 dragged to 80 ended at [50, 80], while the same drag from [30, 50] stops at [50, 50]. Only the press that waits for its first movement, on the thumbs or on their shared value, now marks the drag, as FR6 states.
|
/approve-spec 1115a21 |
There was a problem hiding this comment.
Approval recommended: FR6 is approved by an engineering owner for this head, and the coincident-thumb press rule now behaves exactly as it states, including the fix that keeps a drag begun with a track press on its own thumb. The new cases reproduce each stuck gesture against main and pass here, and the description now states accurately which gestures already worked. Nothing further is needed from the contributor.
[Automated review]
…he upper thumb, as a press on the thumbs does (#9184) <!-- template: bug-fix.md --> Follow-up to #8151. One change on `main`, with no dependencies. ## User impact When both thumbs of a range Slider share a value, the upper thumb is drawn over the lower one. A press on the thumbs that never moves leaves the press and focus on that visible thumb, but a press on the mark label of their shared value takes the lower, covered thumb: the focus ring and pressed look land on a thumb you can't see, and the next arrow key moves it. ## Problem and solution fit 1. **Why it happens:** a press that waits for its first movement holds the thumb it landed on. A mark label is no thumb, so it falls back to the closest-thumb rule, which prefers the lower thumb on a tie. 2. **Why it matters:** focus decides which thumb the keyboard moves, and the pressed look shows which thumb the pointer holds; both should follow the visible thumb. A waiting press is now held by the upper thumb wherever it landed. The first movement still picks the thumb that can travel that way. ## Expected behavior and authority - `component:Slider` FR6, amended here: until the first movement, the upper thumb holds the press, its focus and its pressed state, so a press that never moves changes no value and leaves focus on the upper thumb; this covers a press on the shared value's mark label. It waits on the spec owner's approval of that text. - `design:user-states` DR4: the pressed overlay follows the thumb the pointer holds. ## Smallest restoration `Slider.tsx`: in the press handler, a waiting press that hit no thumb is held by the upper thumb. `Slider.spec.md`: FR6's sentence and its verification row. No new prop, style or visual. ## Evidence - Before: both thumbs at 50, a press on the "50%" label shows the pressed look on the lower thumb and focuses it. - After: the upper thumb shows pressed and keeps focus; releasing without moving leaves both values at 50. - Unchanged: a press on the thumbs already held the upper thumb; a track press beside them still takes the thumb on its side. - Regression test: "coincident range thumbs" in `Slider.test.tsx` gains two cases. The mark-label case fails without the fix; the on-thumb case pins what already worked. ## Scope - [x] One defect is restored. - [x] Separable contradictory or unsettled tagalongs were removed or split. - [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label. - [x] Public text and artifacts contain no internal Meta context. ## Testing On a range Slider with a mark at 50 and both thumbs at 50, with a mouse: press the "50%" label, or the thumbs, and release without moving. The upper thumb shows pressed and keeps focus, and the values stay at 50. A drag left from the label still moves the lower thumb. Local gates at f75af1f: root build, typecheck, lint, Prettier, `check:repo`, `check:knowledge`, the CLI isolation test (34/34), the Storybook build, Slider's Chromium accessibility suites (13/13), `pnpm test:ui` (17,087 passed), and the node project apart from `cache.test.mjs`, whose failure is known on `main` and has an open fix (#8520). ## Writing rubric results - R1 narration: none; FR6's added sentence states the rule in the present tense. - R2 research: none. - R3 evidence: FR6's basis stays "Current source and focused tests". - R4 rejected alternatives: none added. - R5 change references: none. - R6 open questions: none touched.
Sibling: #7516 (off-grid max). One change on
main, with no dependencies.User impact
Found during the UIKit-parity work on Slider (
spec:AST-094). A range Slider whose two thumbs share a value gets stuck. With both at the maximum, dragging down moves nothing; with both in the middle, a track press above them moves nothing. It happens with a mouse, a finger and a pen.Problem and solution fit
mainonly a track press below them or a drag toward the maximum works.Only one thumb can move toward a given value, so that thumb takes the press. A track press beside them picks the thumb on its side. A press on the thumbs waits for the pointer's first movement, whose direction picks the thumb, with its focus, pressed look and tooltip. A drag that passes the other thumb's value hands itself over.
Expected behavior and authority
component:SliderFR1 / AR1: two thumbs bound the range and never cross.architecture:interaction-modalityINV4: every modality has an operable path.design:user-statesDR4: the pressed overlay follows the dragged thumb.component:SliderFR6, added here: which thumb a press takes when both share a value, and the consequence that a drag coming back past the shared value moves the other thumb. It waits on the spec owner's approval. The alternative, keeping one fixed thumb, is what leaves a direction stuck.Smallest restoration
Slider.tsxonly: the press and move handlers, and the value tooltip'sisOpenduring a drag. No new prop, style or visual.Slider.spec.mdgains FR6 and its verification row.Evidence
iOS 26.2 simulator, Mobile Safari,
mainover this branch.Scope
Testing
On a range Slider story, with a mouse or a finger:
main, nothing moves).Local gates at 1115a21: root build, typecheck, lint, Prettier,
check:repo,check:knowledge, the CLI isolation test (34/34), the Storybook build, Slider's Chromium accessibility suite (7/7),pnpm test:ui(16,465 passed), and the node project apart fromstory-tree.test.tsandcache.test.mjs, whose failures are known onmainand have open fixes (#8509, #8520). "Coincident range thumbs" inSlider.test.tsxautomates each step; withmain'sSlider.tsx, 7 of its 11 cases fail, and the other 4 guard paths that already work, including a drag that began with a track press beside the thumbs, which stays on its thumb.Writing rubric results