You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fe89a20
Browse filesBrowse the repository at this point in the historyBrowse files
feat(SegmentedControl): the selection slides on every change and drags with any pointer
Under a finger the selection slides between segments on
UISegmentedControl's measured spring (the internal role
`segmented.selectionSpring`), for taps, arrow keys and programmatic changes
alike; under Reduce Motion it cross-fades in place. A press shows the shared
pressed overlay and nothing dims. Dragging the selected segment carries the
selection with the pointer and commits once, at the lift, on the segment
under it; a lift outside the control selects nothing. Under Reduce Motion
a drag still follows the pointer, and only the release cross-fades. A mouse
or a pen drags the selection the same way, every change slides on the
theme's timing, a click included, and a press while focus is in the
control no longer selects before the click.
useMediaQuery, which SegmentedControl now reads, returns its server default
where the window has no matchMedia, instead of throwing.
The SegmentedControl record states the slide, the drag, the label color and
the commit at the lift (FR9-FR13, PR2), carried over from meta#8596's
owner-decided clauses as built. Both SegmentedControl records drop the
implementation gaps this closes, and the touch presentation spec names the
new motion role. The action-group tracker owns the tap path's click helpers,
which SegmentedControl now calls.
Combines meta#8094, meta#8127 and meta#8724.
Co-authored-by: Cindy Zhang <cindyxz@meta.com>
[feat] SegmentedControl: under a finger, on a touch device (a coarse primary pointer), the control tracks the touch. Dragging the selected segment carries the selection along with the finger, and the segment under the finger is chosen when it lets go (`onChange` fires once, at the lift); letting go outside the control selects nothing. While the selection is dragged, the selected label's colour follows it, with a margin around each boundary so a finger resting on one never flickers; label weights change only at the lift, so nothing reflows under the finger. A tap selects through the browser's own click, and a pressed segment shows the shared pressed overlay; nothing lifts or dims. A vertical drag that starts on the control still scrolls the page. A commit the item's `onClick` vetoes sends the selection back at once; one a controlled parent adopts later lands without a bounce. With Reduce Motion the selection still follows the finger, with no chase, and only the lift cross-fades. Keyboard and assistive technology keep the click; no element is added.
[feat] SegmentedControl: a mouse or a pen drags the selection as a finger does. A drag from the selected segment carries it with the pointer, and the release commits the segment under the pointer (`onChange` fires once, at the release). A release outside the control selects nothing, and a drag that starts on another segment commits where it lifts. Under a mouse or a pen, every change slides the selection on the theme's duration and easing, not UIKit's spring, and a click slides it too. Keyboard and assistive technology keep the click.
[feat] SegmentedControl: under a finger the selection slides to the new segment on UIKit's spring, whether a tap, an arrow key or a new `value` moved it. The selection indicator is the control's own pseudo-element, so no element is added. The motion runs on the compositor and keeps moving while the main thread is busy. With Reduce Motion nothing travels or scales: the old selection fades out where it is as the new one fades in. The spring is UIKit's measured one, an internal motion role no theme retunes, and no theme value lengthens the Reduce Motion fade. With a mouse or a pen it slides on the theme's duration and easing instead.
[fix]`useMediaQuery` returns its server default where the window has no `matchMedia`, as in a test DOM, instead of throwing. Components that read it, such as SegmentedControl, now render in such a DOM.
Copy file name to clipboardExpand all lines: apps/storybook/stories/SegmentedControl.stories.tsx
+52Lines changed: 52 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ import {
6
6
SegmentedControl,
7
7
SegmentedControlItem,
8
8
}from'@astryxdesign/core/SegmentedControl';
9
+
import{Button}from'@astryxdesign/core/Button';
9
10
import{Card}from'@astryxdesign/core/Card';
10
11
import{Heading}from'@astryxdesign/core/Heading';
11
12
import{Icon}from'@astryxdesign/core/Icon';
@@ -356,3 +357,54 @@ export const PressedState: Story = {
356
357
);
357
358
},
358
359
};
360
+
361
+
constPERIODS=[
362
+
{value: 'day',label: 'Day'},
363
+
{value: 'week',label: 'Week'},
364
+
{value: 'month',label: 'Month'},
365
+
{value: 'year',label: 'Year to date'},
366
+
];
367
+
368
+
/**
369
+
* On a touch screen the selection slides from one segment to the next on
370
+
* UIKit's spring, whether a finger, a key or the app changed the value. With a
371
+
* mouse or a pen every change, a click included, slides on the theme's
372
+
* duration and easing, and a drag carries it as a finger does.
373
+
*/
374
+
exportconstSelectionMotion: Story={
375
+
name: 'Selection motion',
376
+
parameters: {
377
+
docs: {
378
+
description: {
379
+
story:
380
+
'Under a finger the selection slides between segments on UIKit’s spring, for taps, arrow keys and programmatic changes alike (the button changes the value from outside). Drag the selected segment to another one and let go: the segment under the finger is chosen, and letting go outside the control selects nothing. Under Reduce Motion nothing travels: the old selection fades out as the new one fades in. With a mouse or a pen every change, a click included, slides on the theme’s duration and easing, and a drag carries the selection as a finger does.',
@@ -155,6 +158,7 @@ a measured, sourced difference exists.
155
158
|`springs.contextMenuLift`| damping ratio 0.8, response 0.32 s | measured: UIContextMenuInteraction's preview lift, iOS 26.2 simulator, 2026-10-23 |
156
159
|`springs.contextMenuDismiss`| damping ratio 0.85, response 0.35 s | measured: UIContextMenuInteraction's dismissal, iOS 26.2 simulator, 2026-10-23 |
157
160
|`springs.contextMenuMorph`| damping ratio 0.8, response 0.3 s | measured: UIContextMenuInteraction's menu entrance and preview shadow, iOS 26.2 simulator, 2026-10-23 |
@@ -212,7 +216,7 @@ a measured, sourced difference exists.
212
216
activation stays the browser's click, except that an action a
213
217
`family:action-groups` member tracks activates at the lift (FR26), and a toggle
214
218
under `spec:AST-020` FR9's slide-off exception (Switch, Checkbox,
215
-
CheckboxListItem) may also complete on a lift after the finger slid off. Where the engine hit-tests an element a compositor animation moves at the motion's start (iOS WebKit), a touch on moving content goes to what was drawn under the finger at touch-down, and a tap there (no recognizer claimed it, the browser did not take it, and it stayed within 45 pt) MUST activate it: the browser's own click for that touch is cancelled or swallowed, and that element receives one click, an editable focused first.
219
+
CheckboxListItem) may also complete on a lift after the finger slid off; and a drag that carries SegmentedControl's selected surface commits at the lift on the segment nearest the pointer (`component:SegmentedControl` FR13). Where the engine hit-tests an element a compositor animation moves at the motion's start (iOS WebKit), a touch on moving content goes to what was drawn under the finger at touch-down, and a tap there (no recognizer claimed it, the browser did not take it, and it stayed within 45 pt) MUST activate it: the browser's own click for that touch is cancelled or swallowed, and that element receives one click, an editable focused first.
216
220
Under a fine pointer a control uses a third profile with no delay: its
217
221
press paint starts at once on `pointerdown`, through the same press
218
222
controller and release fade as a finger's, in place of CSS `:active`; the
0 commit comments