Repository navigation
feat(SegmentedControl): a drag that drifts off keeps choosing - #10978
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| SegmentedControl | 98.5 kB (+1.4 kB) · 6.9 kB CSS (0) | — | ✗ · ✓ · ✓ |
| SegmentedControlItem | 17.5 kB (0) · 4.3 kB CSS (0) | — | ✗ · ✓ · ✓ |
| DateTimeInput | 210.6 kB (+454 B) · 18.7 kB CSS (0) | — | — · — · — |
12 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/CommentThread | 347.5 kB (+390 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/Comments | 354.4 kB (+378 B) · 2.5 kB CSS (0) | — | — · — · — |
| AlertDialog | 106.9 kB (+373 B) · 14.6 kB CSS (0) | — | — · — · — |
| lab/TabBar | 81.6 kB (+358 B) · 1.8 kB CSS (0) | — | — · — · — |
| ButtonGroup | 42.2 kB (+357 B) · 3.7 kB CSS (0) | — | — · — · — |
| ToggleButtonGroup | 39.7 kB (+354 B) · 3.7 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 280.4 kB (+344 B) · 454 B CSS (0) | — | — · — · — |
| ToggleButton | 87.9 kB (+334 B) · 10.1 kB CSS (0) | — | — · — · — |
| lab/Schedule | 107.4 kB (+326 B) · 3.9 kB CSS (0) | — | — · — · — |
| RadioList | 57.3 kB (0) · 7.3 kB CSS (0) | — | ✓ · ✓ · ✓ |
| RadioListItem | 68.4 kB (0) · 10.1 kB CSS (0) | — | ✓ · ✓ · ✓ |
| lab/TabBarItem | 3.9 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
Visual changes: 1 snapshot in 1 component
A change is a question for the reviewer, not a failure.
| Component · story | Before | After | Diff |
|---|---|---|---|
| SegmentedControl · Default (neutral, dark) | ![]() |
![]() |
![]() |
Package size: @astryxdesign/core 7.29 MB packed (+3.2 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 36 rows, core 36 rows; run pnpm api:report.
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
42deae9 to
c3b4509
Compare
There was a problem hiding this comment.
Approval waits on an owner decision about the proposed SegmentedControl drift rule, and three changes are needed besides.
This pull request replaces the current rule that a press which slides off the control selects nothing (spec:AST-020 FR9 and DEC-5, component:SegmentedControl FR3 and FR13) with new, unapproved architecture:interaction-modality INV14, spec:AST-020 DEC-6 and FR3/FR13 text, and because it also changes what a mouse or trackpad does, the record should trace that decision for desktop input with the words and when and where they were given. An engineering owner records the decision by commenting /approve-spec <full head SHA> on the pull request, and the author may do so as an engineering owner.
Blocking findings:
- Escape does not take back a press released on the segment it began on: in Chromium, a mouse press on List, then Escape, then release on List still selects List through the browser's own click, so the cancel path in
useSegmentedTouchTracking.tsshould take that click and a browser test should cover it. - The proposed records contradict themselves: DEC-6 says "DEC-5 stands for the controls it names" while DEC-5 still names SegmentedControl, and the SegmentedControl record's compatibility row, FR3 basis and FR12/FR13 verification row still say a lift outside the control selects nothing.
- The Changeset is tagged
[fix]and the title saysfix(...)for what the description calls a decided behavior change, whichspec:AST-017FR5 does not count as a fix, so it needs a different tag and a note that mouse drags change too.
Not blocking: an Escape that takes back a press inside a Dialog, Drawer or BottomSheet also closes it, because the tracker never marks the key handled.
[Automated review]
|
/approve-spec c3b4509 |
There was a problem hiding this comment.
Changes requested: the SegmentedControl drift rule now has engineering-owner approval at this head, but the change does not meet it everywhere yet.
- Escape does not take back a press released on the segment it began on: in Chromium, a mouse press on List, then Escape, then release on List still selects List through the browser's own click, so the cancelled lift in
useSegmentedTouchTracking.tsshould take that click and a browser test should cover it. spec:AST-020DEC-6 says "DEC-5 stands for the controls it names" while DEC-5 still says SegmentedControl keeps slide-off cancelling, so DEC-6 should state that it replaces that clause.- The SegmentedControl record's compatibility row, FR3 basis and FR12/FR13 verification row still say a lift outside the control selects nothing, which contradicts the new FR13.
- Miss:
SegmentedControl.doc.mjsstill tells builders, in all three of its descriptions, that letting go outside the control selects nothing. - The Changeset is tagged
[fix]and the title saysfix(...)for what the description calls a decided behavior change, whichspec:AST-017FR5 does not count as a fix, so it needs another tag and a note that mouse drags change too.
Not blocking: an Escape that takes back a press inside a Dialog, Drawer or BottomSheet also closes it, because the tracker never marks the key handled. The approval binds this exact head, so the fixed head needs a fresh /approve-spec.
[Automated review]
c3b4509 to
879aac8
Compare
|
On the latest review, at 879aac8: each inline point has its answer on its thread.
|
|
/approve-spec 879aac8 |
There was a problem hiding this comment.
Changes requested: the drift rule itself is approved by an engineering owner for this head, and one fix remains before it can merge.
- After Escape, a press released on the segment it began on more than 400 ms later, or after dragging away and back, still selects that segment, because the click guard armed at the key press (
useSegmentedTouchTracking.ts:209-214) disarms itself after 400 ms; arm it at the cancelled press's lift as well, and add browser cases that hold past 400 ms and that drag back before release.
Two smaller points that do not block: during a mouse drag from an unselected segment both the origin and the segment the lift will commit look pressed, and the per-press lift-area measurement can no longer change a result. CI has not run on this draft head yet.
[Automated review]
879aac8 to
fde848a
Compare
|
At fde848a, on this review's two non-blocking notes:
|
|
/approve-spec fde848a |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because the pull request is a draft from a fork. Mark it ready for review, and a maintainer adds the ci:run label so CI runs.
The drift rule (INV14, DEC-6, FR3 and FR13) has an engineering owner's approval for this head. The Escape cancel now takes back a press at any hold: the new mouse cases fail on the previous head's build and pass here.
Non-blocking, for a follow-up:
- During a mouse drag from another segment, two segments look pressed: the starting one (
:active) and the one the lift will commit. measureLiftAreaand the outside branch ofliftTargetAtno longer change a result. Two comments are flagged inline.
[Automated review]
| /** The segments as the finger found them (disabled ones too). */ | ||
| const segmentsRef = useRef<SegmentSpan[]>([]); | ||
| /** The lift area as the finger found it: a lift outside it cancels. */ | ||
| /** The lift area as the finger found it. */ |
There was a problem hiding this comment.
Non-blocking: nothing decides a lift from this area any more. The tracker hands liftTargetAt a point on the control's center line, so its outside branch never runs, yet measureLiftArea still reads layout on every press (line 269). Consider removing the area, that read and the outside branch together, with the unit case that pins a null the tracker never produces. Until then, this doc only restates the name (INV29).
| let lastX = 0; | ||
| let lastY = 0; | ||
| const fades = new Map<Element, ReturnType<typeof setTimeout>>(); | ||
| // A one-axis group's box, read at the begin: the finger counts inside it. |
There was a problem hiding this comment.
Non-blocking (INV29): the finger counts on this box's center line, not inside it. Suggested: // Read at the begin. A one-axis group counts the finger on this box's center line.
A press on SegmentedControl that drifted off the control cancelled at the lift, so a drag that left it vertically selected nothing while the highlight kept following the finger. The shared action-group tracker now tracks a one-axis group along its axis: a held pointer counts on the group's center line, clamped to its ends, and the lift commits the segment under its horizontal position. Escape or a browser cancel takes the press back, and the highlight returns at once. During a drag from another segment, the segment the lift would commit shows the press paint. interaction-modality INV14, a new AST-020 decision for one-axis controls and SegmentedControl FR3 state the rule and its cancel cases. SegmentedControl's options take the radio-group contract's aborted-press check through their own abort: a return to the current choice before the lift.
fde848a to
3bc5fe8
Compare
|
/approve-spec 3bc5fe8 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because the pull request is a draft from a fork. Mark it ready for review, and a maintainer adds the ci:run label so CI runs.
The drift rule (INV14, DEC-6 with its FR9 sentence, FR3 and FR13) has an engineering owner's approval for this head, and the SegmentedControl interaction specs and the radio-group contract pass in Chromium here.
Non-blocking, for a follow-up:
measureLiftAreaand the outside branch ofliftTargetAtno longer change a result, yet the area is still measured on every press.- Miss: two unchanged comments still describe the old rule,
SegmentedControl.tsx:331anduseSegmentedSelectionMotion.ts:410-411("A lift outside the control commits nothing"). - During a mouse drag from another segment, two segments look pressed: the starting one (
:active) and the one the lift will commit.
[Automated review]



Primary intent
Carry out a design-review decision on a held press that leaves a SegmentedControl. Not a bug fix: it changes the interaction model by decision. Not specification-only: the code ships with its records.
User or maintainer impact
Today a drag that leaves the control vertically selects nothing at the lift, while the highlight keeps following the finger. Now the press keeps choosing by its horizontal position, however far it drifts, and the lift commits that segment. A mouse or a pen drags the same way. Past either end, the end segment counts.
Only a cancel commits nothing:
pointercancel(a system gesture, or a page scroll that claims the touch first) or Escape. The highlight then returns to the selected segment at once. During a drag from another segment, the segment the lift would commit shows the press paint.Accessibility contract consequence
The shared radio-group contract's required aborted-press check releases 200 px away and expects no change. A release straight away now chooses by position, so SegmentedControl's options take that check through their own abort. The press slides off the control in the current choice's column and lifts there. WCAG 2.5.2 is met by that abort, Escape, and undo, which the contract's pointer round trip covers.
Problem and solution fit
actionGroupTracker) gainstracksAlong: a one-axis group counts a held pointer on its center line, clamped to its ends. Escape cancels such a press, andonCanceltells the owner.paintsHighlightalso takes a function, so SegmentedControl paints only the segment a drag from another segment would commit.'x'. On Escape it cuts the press paint and returns the lens.Authority
architecture:interaction-modalityINV14 (new): a one-axis group that chooses tracks along its axis. Button groups and menus keep their slide-off rule.spec:AST-020DEC-6 (new) quotes the design review, covers SegmentedControl only, and replaces DEC-5's SegmentedControl clause. After design review confirmed it for a mouse and a pen, the spec owner approved it at fde848a (/approve-spec).component:SegmentedControlFR3 lists the cancel cases, and FR13 follows it./approve-spec <head sha>): all three records.Writing rubric results
INV14, DEC-6, FR9's sentence, FR3 and FR13: R1–R6 none. DEC-6 quotes the design review verbatim, and its next sentence states the meaning.
Scope
Testing
On a phone, open SegmentedControl in the preview. Press the selected segment, slide to another one, drag well below the control and lift: that segment is selected. Press, drag, then press Escape: nothing changes.
pnpm lint:strict(CI's mode), core typecheck,check:knowledge, units (SegmentedControl, hooks, RadioList)check:knowledge, SegmentedControl units, public textcheck:knowledge,specs:for --diff, changesets, public text