Skip to content

fix(Slider): preserve max for pointer endpoint selection - #7516

Open
korkt-kim wants to merge 6 commits into
meta:mainfrom
korkt-kim:fix/slider-pointer-max
Open

korkt-kim wants to merge 6 commits into
meta:mainfrom
korkt-kim:fix/slider-pointer-max

Conversation

@korkt-kim

@korkt-kim korkt-kim commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

User impact

With min={0}, max={100}, and step={3}, dragging a Slider to the right endpoint leaves its value at 99. Pressing a mark at 100 does the same. A mouse user cannot select the declared maximum, even though End can already reach it.

Problem and solution fit

The pointer position is rounded to the step grid before it is clamped, so the endpoint value 100 becomes 99. The value updater also snaps a mark's value, losing an explicit 100 there.

The fix returns max at the endpoint and uses the existing unsnapped update path when pointer input selects that exact value. The shared thumb-tracking path preserves it during movement and touch finalization too. Bounds and range-thumb separation still apply. Interior positions keep their existing step rounding.

Expected behavior and authority

Selecting max is already supported by the current Slider contract. AR1 states that “Home moves to min and End to max.” #7484 restored that outcome when max is off the step grid. With min=0, max=100, and step=3, 100 is therefore an existing selectable bound, not a new value introduced by this PR.

The current interaction-modality contract, INV4 requires an operable path for every modality: “Keyboard, pointer, and touch or pen can reach each supported interaction.” The restoration argument is that selecting the declared maximum is the same supported value-selection outcome regardless of input modality. This PR restores pointer access to that already-permitted value instead of introducing a new value domain.

Slider ORD1 explicitly assigns snap-then-clamp to arrow and Page key results, while Home and End select the bounds. It does not specify a pointer snapping algorithm. The change preserves those keyboard rules and the existing rounding of interior pointer positions and non-maximum marks; only a pointer-selected max uses the existing unsnapped update path. Clamping and minimum range-thumb separation still apply.

The basis for treating this as a narrow restoration is AR1's already-supported maximum together with INV4's cross-modality reachability, not a claim that ORD1 explicitly approves the particular pointer endpoint algorithm. No wider nearest-value rule or adjacent-arrow policy is included.

Smallest restoration

Preserve max through track selection and the shared thumb-tracking path, including coincident-thumb hand-off and touch finalization. Two new regression tests and stronger existing mark/touch endpoint tests cover the distinct paths, with a changeset. No new props, styling, or layout changes. Keyboard snapping, drag thresholds, and range-thumb separation stay unchanged.

Evidence

  • Before (2680926f96): with min=0, max=100, and step=3, a thumb drag beyond the endpoint, an endpoint click, and a click on the 100 mark all leave the rendered value and onChangeEnd at 99.
  • After (59ef058bd2): the same actions select 100 and report 100 through onChangeEnd. Touch endpoint and max-mark taps also settle at 100.
  • Representative unchanged paths: an interior position still rounds to 99; End → ArrowLeft remains 100 → 96. Browser checks cover horizontal RTL, vertical input, coincident-thumb hand-off, minimum range separation of six units, disabled input, and re-enabling.
  • Regression proof: the four endpoint checks observe 99 instead of 100 when only Slider's source is substituted with immutable main source at 2680926f96. The current Slider suite passes all 179 tests. Restoring snapping only in the final touch commit makes the strengthened touch test observe 99, proving that finalization is covered independently of movement.

Both videos use real mouse and keyboard input in Playwright Chromium 149.0.7827.55 on macOS, at 1000 × 680 with the same controlled fixture and light appearance. Readouts show actual rendered state and callbacks. The AS-IS build substitutes only immutable base Slider source; TO-BE uses the proposed source. Recording fixtures are not part of the PR.

AS-IS

slider-pointer-max-as-is.mp4

TO-BE

slider-pointer-max-to-be.mp4

Scope

  • One pointer endpoint defect is addressed.
  • The wider nearest-value and adjacent-arrow proposals are excluded.
  • No new public API, visual representation, or hidden interaction-model change is included.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project ui packages/core/src/Slider --maxWorkers=2 — 7 files, 179 tests passed.
  • pnpm lint:strict — passed, zero errors.
  • pnpm build — passed.
  • pnpm -F @astryxdesign/core typecheck — source, tests, and consumer docs passed.
  • Prettier, check:changesets, git diff --check, and pnpm review:pre --head HEAD — passed.
  • Chromium mouse/keyboard and touch checks described above — passed.

Related Issues

Addresses the remaining pointer endpoint part of #6735, following the End-key fix in #7484.
This PR supersedes #6399 with a more focused fix for the Slider pointer endpoint issue.

@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 20, 2026 1:00am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 14, 2026
@astracat-bot

astracat-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 20, 2026, 1:13 AM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 8295d89

⏳ Building… Until it's ready, Storybook · Sandbox open the branch's previous preview.

Current run: The current CI run concluded failure. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@korkt-kim
korkt-kim marked this pull request as ready for review October 14, 2026 10:57

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused fix and the regression tests: the code does what the description says and this review found no defects, so approval is waiting on a maintainer decision rather than on changes from you. Slider's current spec settles only the keyboard bounds (End reaches max; arrow and Page keys snap, then clamp), so a maintainer needs to provide or identify the governing spec for pointer input reaching an off-grid max, specifically whether pressing or dragging to the end of the track and pressing a mark at max should select max while every other position and mark keeps rounding to the step grid. You don't need to write that spec; if it is settled as implemented here, the change is ready for normal approval, and since #6399 touches the same code for the broader policy, one decision should cover both.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused fix and the regression tests: this review found no defects, so approval is waiting on a maintainer decision rather than on changes from you. Slider's current spec settles only the keyboard bounds (End reaches max; arrow and Page keys snap, then clamp) and leaves pointer behavior to the component's own contract, so a maintainer needs to provide or identify the governing spec for pointer input reaching an off-grid max: whether pressing or dragging to the end of the track, and pressing a mark at max, should select max while every other position and mark keeps rounding to the step grid. You don't need to write that spec; if it is settled as implemented here, the change is ready for normal approval, and if a different rule is chosen (such as the nearest-value rule in #6399), the endpoint code and the two tests would need to follow it.

[Automated review]

Comment thread packages/core/src/Slider/Slider.tsx Resolved

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused fix and the regression tests: this review found no defects, so approval is waiting on a maintainer decision rather than on changes from you. Slider's current spec settles only the keyboard bounds (End reaches max; arrow and Page keys snap, then clamp), so a maintainer needs to provide or identify the governing spec for pointer input reaching an off-grid max: whether dragging or pressing to the end of the track, and pressing a mark at max, select max while every other position and mark keeps rounding to the step grid. You don't need to write that spec; if it is settled as implemented here, the change is ready for normal approval, and if a different rule is chosen (such as the nearest-value rule in #6399), the endpoint code and the two tests would need to follow it.

[Automated review]

@korkt-kim

korkt-kim commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@cixzhang could you take a look when you have a chance? This is a focused pointer-endpoint fix following #7484, with before/after videos in the description.

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused fix and the regression tests: the change does what the description says, but approval waits on a decision the current Slider spec does not make, namely whether pointer input selects an off-grid max at the end of the track and from a mark at max while every other position and mark keeps rounding to the step grid. An engineering owner needs to provide or identify that rule and can record it by commenting /approve-spec with this pull request's full head commit SHA (the author can do so only as an engineering owner); you don't need to write the spec. Independently of that decision, two changes are needed:

  • Reword the changeset: with step={6} or step={40} on 0–100, max was already reachable, so the issue only occurs when max lies less than half a step past the last step value (for example step={3}).
  • Rebase onto main, where Slider.tsx now conflicts; its reworked pointer handlers add a third updateValue call (the coincident-thumb hand-off) that needs the same max rule.

[Automated review]

cixzhang pushed a commit that referenced this pull request Oct 24, 2026
<!-- 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.
cixzhang pushed a commit that referenced this pull request Oct 31, 2026
<!-- template: bug-fix.md -->

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

1. **Why it happens:** with equal values, a direct press keeps the upper thumb (#6380) and a track press takes the lower one, whichever way the pointer goes, and that thumb is clamped against its sibling.
2. **Why it matters:** coincident thumbs are a normal state, and in those directions no pointer path moves them; on `main` only 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:Slider` FR1 / AR1: two thumbs bound the range and never cross. `architecture:interaction-modality` INV4: every modality has an operable path. `design:user-states` DR4: the pressed overlay follows the dragged thumb.
- `component:Slider` FR6, 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.tsx` only: the press and move handlers, and the value tooltip's `isOpen` during a drag. No new prop, style or visual. `Slider.spec.md` gains FR6 and its verification row.

## Evidence

![Coincident thumbs dragged down: main moves nothing; here the lower thumb follows](https://raw.githubusercontent.com/vjeux/astryx/2ff402db2ed766013b6da91447e73905d6cd4fe8/slider-8151-coincident.gif)

![Only the dragged thumb's tooltip stays open](https://raw.githubusercontent.com/vjeux/astryx/2ff402db2ed766013b6da91447e73905d6cd4fe8/slider-8151-tooltip.gif)

iOS 26.2 simulator, Mobile Safari, `main` over this branch.

## 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 story, with a mouse or a finger:

1. Both thumbs at the maximum, drag down: the lower thumb follows (on `main`, nothing moves).
2. Both in the middle, press the track above them: the upper thumb moves there; below, the lower one.
3. Press on both thumbs and move: the direction picks the thumb; the other's tooltip closes.
4. Repeat step 1 in RTL: mirrored.

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 from `story-tree.test.ts` and `cache.test.mjs`, whose failures are known on `main` and have open fixes (#8509, #8520). "Coincident range thumbs" in `Slider.test.tsx` automates each step; with `main`'s `Slider.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

- R1 narration: none; FR6 states the rule and its consequence in the present tense.
- R2 research: none.
- R3 evidence: FR6's basis is the current source and focused tests.
- R4 rejected alternatives: none added to the record.
- R5 change references: none.
- R6 open questions: none touched.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused fix and the red-first tests: this review found no defect, so approval waits on a Slider rule rather than on changes from you. The Slider spec defines only the keyboard path to an off-grid max (End), so a maintainer needs to provide or identify the rule for pointer input: whether a press or drag at the end of the track's travel, and a press on a mark whose value is max, select that max while every other position and mark keeps rounding to the step grid (with step={3} the 50 mark still selects 51). An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (the author can do so only as an engineering owner), and you don't need to write the spec. CI has not run on this head yet: a maintainer adds the ci:run label so it runs.

Claims and files checked
  • Before the fix, with 0 to 100 and step 3, a drag to the end, a press at the end and a press on the 100 mark stop at 99: verified (the new tests fail with 99 on the base source; the same in Chromium).
  • End already reaches the maximum: verified (keyboard handler and its existing off-grid End test).
  • Pointer positions round to the grid before the clamp, and the value updater snaps a mark's value: verified (base getValueFromPosition and updateValue).
  • The fix returns max at the end of travel and uses the existing unsnapped path when pointer input selects max: verified (Slider.tsx:931-934, :1160, :1253).
  • Thumb tracking keeps max during movement, touch finalization and the coincident-thumb hand-off: verified in code (:1249, :1274-1276, :1296-1297, :1322); the hand-off has no unit test.
  • Bounds and range separation still apply, and interior positions keep rounding: verified (:979-1005; the interior-position test; a press 3 px short of the end still selects 99).
  • Keyboard snapping, drag thresholds and range separation are unchanged, with no new props, styling or layout: verified (keyboard handler untouched; the built API surface is identical).
  • Restoring snapping only in the final touch commit makes the strengthened touch test fail: verified (it then reports 99).
  • The four endpoint checks fail on the base source, and the Slider suites pass 179 tests: verified.
  • Lint, formatting, typecheck and the changeset check pass: verified for the changed files and the core typecheck.
  • The changeset says Slider reaches its explicit maximum at the track endpoint or the max mark even when step rounding would select a lower value: verified.
  • Browser checks for right-to-left, vertical, hand-off, range separation and disabled input, and the before and after videos: stated in the description and not re-run here; right-to-left and vertical follow from the direction-aware fraction in code.
  • .changeset/slider-pointer-max.md: clear.
  • packages/core/src/Slider/Slider.tsx: clear, with one optional comment-style suggestion inline.
  • packages/core/src/Slider/Slider.test.tsx: clear.
  • packages/core/src/Slider/useSliderTouch.test.tsx: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Slider/Slider.tsx Resolved
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 20, 2026
@cixzhang
cixzhang marked this pull request as draft November 20, 2026 00:16
@cixzhang
cixzhang marked this pull request as ready for review November 20, 2026 00:17
@cixzhang cixzhang removed the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 20, 2026
The mouse gesture ends when a move reports no buttons. Send the held primary button so the regression reaches the off-grid maximum. Clarify why endpoint updates skip snapping.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused fix and the red-first tests: this review found no defect, so approval waits on a Slider rule rather than on changes from you. The Slider spec defines only the keyboard path to an off-grid max (End), so a maintainer needs to provide or identify the rule for pointer input: whether a press or drag at the end of the track's travel, and a press on a mark whose value is max, select that max while every other position and mark keeps rounding to the step grid (with step={3} the 50 mark still selects 51). An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (the author can do so only as an engineering owner), and you don't need to write the spec. CI has not run on this head yet: a maintainer adds the ci:run label so it runs.

  • Optional, if the rule is accepted: a test that reaches max through the coincident-thumb hand-off would cover the one pointer path no test checks today.
Claims and files checked

Review mode: full; reason: author-not-engowner

  • Before the fix, with 0 to 100 and step 3, a drag past the end, a press at the end and a press on the 100 mark stop at 99: verified (the new tests fail with 99 on the base source; the same in Chromium, together with a finger tap at the end).
  • End already reaches the maximum: verified (keyboard handler and its existing off-grid End tests).
  • Pointer positions round to the grid before the clamp, and the value updater snaps a mark's value: verified (base position mapping and value updater).
  • The fix returns max at the end of travel and uses the existing unsnapped path when pointer input selects max: verified (Slider.tsx:950-953, :1179, :1272).
  • Thumb tracking keeps max during movement, touch finalization and the coincident-thumb hand-off: verified in code (:1268, :1293-1295, :1316, :1341); restoring snapping in the hand-off leaves every test passing.
  • Bounds and range separation still apply, and interior positions keep rounding: verified (:998-1024, :1299-1303; the interior-position test; a press just short of the end still selects 99 in Chromium).
  • Keyboard snapping, drag thresholds and range separation are unchanged, with no new props, styling or layout: verified (keyboard handler untouched; the built API surface compares with no change).
  • Restoring snapping only in the final touch commit makes the strengthened touch test fail: verified (it reports 99).
  • The four endpoint checks fail on the base source, and the Slider suites pass: verified (four fail with 99; all 180 tests pass on this head, one more than the description counts, after the merges from main).
  • Lint, formatting, build, typecheck and the changeset check pass: verified for lint and formatting of the changed files, the core and theme builds, the core typecheck and the changeset check.
  • The changeset says Slider reaches its explicit maximum at the track endpoint or the max mark even when step rounding would select a lower value: verified.
  • Browser checks for right-to-left, vertical, hand-off, range separation and disabled input, and the before and after videos: stated in the description; the Chromium endpoint, mark and tap checks were repeated here, and right-to-left and vertical follow from the direction-aware fraction in code.
  • .changeset/slider-pointer-max.md: clear.
  • packages/core/src/Slider/Slider.tsx: clear.
  • packages/core/src/Slider/Slider.test.tsx: clear.
  • packages/core/src/Slider/useSliderTouch.test.tsx: clear.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — 8295d894 Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants