Skip to content

feat: React 19 transitions with onChangeAction/onClickAction - #146

Merged
cixzhang merged 5 commits into
mainfrom
react-transitions-v2
Feb 24, 2026
Merged

cixzhang merged 5 commits into
mainfrom
react-transitions-v2

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Replaces #93 with a clean implementation on top of current main.

Changes

All input components: onChangeAction + isLoading

  • TextInput, TextArea: onChangeAction(value, event) with event.preventDefault() gating
  • CheckboxInput, Switch: onChangeAction(checked, event) with spinner in checkbox/thumb
  • Selector, DateInput, TimeInput: onChangeAction(value) — no event, both fire

Button: onClickAction

  • onClickAction(event) wrapped in useTransition
  • Shows loading spinner while pending

CloseButton

  • Passes onClickAction through to XDSButton

Pattern

onChange always fires first (sync). onChangeAction fires after if not event.defaultPrevented(). Both can be used together:

<XDSTextInput
  value={value}
  onChange={(value, e) => {
    if (!valid(value)) {
      setError('Invalid');
      e.preventDefault(); // blocks the action
    }
  }}
  onChangeAction={async (value) => {
    await saveToServer(value);
  }}
/>

Implementation

  • useOptimistic for immediate UI feedback
  • useTransition + startTransition for async wrapping
  • XDSSpinner for loading indicators (no inline CSS spinners)
  • aria-busy for accessibility
  • React 19 upgrade included

749 tests passing

Supersedes #93

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 19, 2026
@cixzhang
cixzhang force-pushed the react-transitions-v2 branch 2 times, most recently from 06d3515 to 101e12e Compare February 19, 2026 18:13
cixzhang and others added 3 commits February 23, 2026 20:53
Update RefObject type parameters to include null across Selector hooks,
useGridFocus, and useListFocus to match React 19's stricter typing where
useRef<T>(null) returns RefObject<T | null>.

Co-authored-by: Navi <[email protected]>
The root package.json was upgraded to React 19 but the workspace apps
(storybook, sandbox, example-vite, example-nextjs) still pinned React 18.
This caused Yarn to create duplicate React installations and broke
hoisting of @storybook/react-vite, failing the Storybook build in CI.
@github-actions

github-actions Bot commented Feb 23, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Button · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 237B N/A
Lines of Code N/A 260 -
Complexity N/A High (21) -
CheckboxInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 443B N/A
Lines of Code N/A 361 -
Complexity N/A Very High (32) -
DateInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 659B N/A
Lines of Code N/A 466 -
Complexity N/A Very High (53) -
Layer
Metric Before After Delta
Bundle Size (ESM) N/A 463B N/A
Lines of Code N/A 1301 -
Complexity N/A Very High (141) -
Selector · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 901B N/A
Lines of Code N/A 928 -
Complexity N/A Very High (53) -
Switch · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 429B N/A
Lines of Code N/A 325 -
Complexity N/A Very High (35) -
TextArea · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 497B N/A
Lines of Code N/A 327 -
Complexity N/A Very High (33) -
TextInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 499B N/A
Lines of Code N/A 302 -
Complexity N/A Very High (31) -
TimeInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 531B N/A
Lines of Code N/A 474 -
Complexity N/A Very High (60) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 7.3KB 11.9KB 1.9KB

Accessibility Audit

Status: No accessibility violations detected.

Component Previews

Includes interactive hover previews as animated GIFs.

XDSButton

Primary

Screenshot:

Primary

Interaction Preview: (view video)

Primary interaction

View in Storybook · core-xdsbutton--primary

Secondary

Screenshot:

Secondary

View in Storybook · core-xdsbutton--secondary

Ghost

Screenshot:

Ghost

View in Storybook · core-xdsbutton--ghost

Destructive

Screenshot:

Destructive

View in Storybook · core-xdsbutton--destructive

Loading

Screenshot:

Loading

View in Storybook · core-xdsbutton--loading

Disabled

Screenshot:

Disabled

View in Storybook · core-xdsbutton--disabled

Size Variants

Screenshot:

Size Variants

View in Storybook · core-xdsbutton--size-variants

Icon Only

Screenshot:

Icon Only

View in Storybook · core-xdsbutton--icon-only

Icon With Text

Screenshot:

Icon With Text

View in Storybook · core-xdsbutton--icon-with-text

All Variants

Screenshot:

All Variants

View in Storybook · core-xdsbutton--all-variants

XDSCheckboxInput

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · form-xdscheckboxinput--default

Checked

Screenshot:

Checked

View in Storybook · form-xdscheckboxinput--checked

With Description

Screenshot:

With Description

View in Storybook · form-xdscheckboxinput--with-description

With Hidden Label

Screenshot:

With Hidden Label

View in Storybook · form-xdscheckboxinput--with-hidden-label

Indeterminate

Screenshot:

Indeterminate

View in Storybook · form-xdscheckboxinput--indeterminate

Disabled

Screenshot:

Disabled

View in Storybook · form-xdscheckboxinput--disabled

Disabled Checked

Screenshot:

Disabled Checked

View in Storybook · form-xdscheckboxinput--disabled-checked

All Variations

Screenshot:

All Variations

View in Storybook · form-xdscheckboxinput--all-variations

Small Size

Screenshot:

Small Size

View in Storybook · form-xdscheckboxinput--small-size

Size Comparison

Screenshot:

Size Comparison

View in Storybook · form-xdscheckboxinput--size-comparison

With Start Icon

Screenshot:

With Start Icon

View in Storybook · form-xdscheckboxinput--with-start-icon

Start Icon Variations

Screenshot:

Start Icon Variations

View in Storybook · form-xdscheckboxinput--start-icon-variations

With Error Status

Screenshot:

With Error Status

View in Storybook · form-xdscheckboxinput--with-error-status

With Warning Status

Screenshot:

With Warning Status

View in Storybook · form-xdscheckboxinput--with-warning-status

With Success Status

Screenshot:

With Success Status

View in Storybook · form-xdscheckboxinput--with-success-status

Status Variations

Screenshot:

Status Variations

View in Storybook · form-xdscheckboxinput--status-variations

XDSDateInput

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · form-xdsdateinput--default

With Value

Screenshot:

With Value

View in Storybook · form-xdsdateinput--with-value

With Description

Screenshot:

With Description

View in Storybook · form-xdsdateinput--with-description

With Hidden Label

Screenshot:

With Hidden Label

View in Storybook · form-xdsdateinput--with-hidden-label

Optional

Screenshot:

Optional

View in Storybook · form-xdsdateinput--optional

Required

Screenshot:

Required

View in Storybook · form-xdsdateinput--required

Disabled

Screenshot:

Disabled

View in Storybook · form-xdsdateinput--disabled

Small Size

Screenshot:

Small Size

View in Storybook · form-xdsdateinput--small-size

With Min Max

Screenshot:

With Min Max

View in Storybook · form-xdsdateinput--with-min-max

Two Month Calendar

Screenshot:

Two Month Calendar

View in Storybook · form-xdsdateinput--two-month-calendar

With Error Status

Screenshot:

With Error Status

View in Storybook · form-xdsdateinput--with-error-status

With Warning Status

Screenshot:

With Warning Status

View in Storybook · form-xdsdateinput--with-warning-status

With Success Status

Screenshot:

With Success Status

View in Storybook · form-xdsdateinput--with-success-status

All Variations

Screenshot:

All Variations

View in Storybook · form-xdsdateinput--all-variations

XDSSelector

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · form-xdsselector--default

Hidden Label

Screenshot:

Hidden Label

View in Storybook · form-xdsselector--hidden-label

With Description

Screenshot:

With Description

View in Storybook · form-xdsselector--with-description

With Objects

Screenshot:

With Objects

View in Storybook · form-xdsselector--with-objects

With Icons

Screenshot:

With Icons

View in Storybook · form-xdsselector--with-icons

With Sections

Screenshot:

With Sections

View in Storybook · form-xdsselector--with-sections

Custom Render

Screenshot:

Custom Render

View in Storybook · form-xdsselector--custom-render

Size Variants

Screenshot:

Size Variants

View in Storybook · form-xdsselector--size-variants

With Status

Screenshot:

With Status

View in Storybook · form-xdsselector--with-status

Optional Required

Screenshot:

Optional Required

View in Storybook · form-xdsselector--optional-required

Disabled

Screenshot:

Disabled

View in Storybook · form-xdsselector--disabled

Pre Selected

Screenshot:

Pre Selected

View in Storybook · form-xdsselector--pre-selected

All Variations

Screenshot:

All Variations

View in Storybook · form-xdsselector--all-variations

XDSSwitch

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · form-xdsswitch--default

On

Screenshot:

On

View in Storybook · form-xdsswitch--on

With Description

Screenshot:

With Description

View in Storybook · form-xdsswitch--with-description

With Hidden Label

Screenshot:

With Hidden Label

View in Storybook · form-xdsswitch--with-hidden-label

Disabled

Screenshot:

Disabled

View in Storybook · form-xdsswitch--disabled

Disabled On

Screenshot:

Disabled On

View in Storybook · form-xdsswitch--disabled-on

Required

Screenshot:

Required

View in Storybook · form-xdsswitch--required

Optional

Screenshot:

Optional

View in Storybook · form-xdsswitch--optional

With Label Icon

Screenshot:

With Label Icon

View in Storybook · form-xdsswitch--with-label-icon

With Label Tooltip

Screenshot:

With Label Tooltip

View in Storybook · form-xdsswitch--with-label-tooltip

Label Position Start

Screenshot:

Label Position Start

View in Storybook · form-xdsswitch--label-position-start

Label Spacing Spread

Screenshot:

Label Spacing Spread

View in Storybook · form-xdsswitch--label-spacing-spread

All Variations

Screenshot:

All Variations

View in Storybook · form-xdsswitch--all-variations

Label Icon Variations

Screenshot:

Label Icon Variations

View in Storybook · form-xdsswitch--label-icon-variations

Label Position Comparison

Screenshot:

Label Position Comparison

View in Storybook · form-xdsswitch--label-position-comparison

Spread Spacing Example

Screenshot:

Spread Spacing Example

View in Storybook · form-xdsswitch--spread-spacing-example

With Error Status

Screenshot:

With Error Status

View in Storybook · form-xdsswitch--with-error-status

With Warning Status

Screenshot:

With Warning Status

View in Storybook · form-xdsswitch--with-warning-status

With Success Status

Screenshot:

With Success Status

View in Storybook · form-xdsswitch--with-success-status

Status Variations

Screenshot:

Status Variations

View in Storybook · form-xdsswitch--status-variations

XDSTextArea

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · form-xdstextarea--default

With Description

Screenshot:

With Description

View in Storybook · form-xdstextarea--with-description

With Hidden Label

Screenshot:

With Hidden Label

View in Storybook · form-xdstextarea--with-hidden-label

With Value

Screenshot:

With Value

View in Storybook · form-xdstextarea--with-value

Custom Rows

Screenshot:

Custom Rows

View in Storybook · form-xdstextarea--custom-rows

All Variations

Screenshot:

All Variations

View in Storybook · form-xdstextarea--all-variations

Optional Field

Screenshot:

Optional Field

View in Storybook · form-xdstextarea--optional-field

Required Field

Screenshot:

Required Field

View in Storybook · form-xdstextarea--required-field

Description With Optional

Screenshot:

Description With Optional

View in Storybook · form-xdstextarea--description-with-optional

Disabled

Screenshot:

Disabled

View in Storybook · form-xdstextarea--disabled

With Start Icon

Screenshot:

With Start Icon

View in Storybook · form-xdstextarea--with-start-icon

Start Icon Variations

Screenshot:

Start Icon Variations

View in Storybook · form-xdstextarea--start-icon-variations

Error Status

Screenshot:

Error Status

View in Storybook · form-xdstextarea--error-status

Warning Status

Screenshot:

Warning Status

View in Storybook · form-xdstextarea--warning-status

Success Status

Screenshot:

Success Status

View in Storybook · form-xdstextarea--success-status

Status Without Message

Screenshot:

Status Without Message

View in Storybook · form-xdstextarea--status-without-message

Status Variations

Screenshot:

Status Variations

View in Storybook · form-xdstextarea--status-variations

With Tooltip

Screenshot:

With Tooltip

View in Storybook · form-xdstextarea--with-tooltip

Tooltip With Optional

Screenshot:

Tooltip With Optional

View in Storybook · form-xdstextarea--tooltip-with-optional

Combined Features

Screenshot:

Combined Features

View in Storybook · form-xdstextarea--combined-features

With Max Length

Screenshot:

With Max Length

View in Storybook · form-xdstextarea--with-max-length

Max Length With Value

Screenshot:

Max Length With Value

View in Storybook · form-xdstextarea--max-length-with-value

Max Length Variations

Screenshot:

Max Length Variations

View in Storybook · form-xdstextarea--max-length-variations

XDSTextInput

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · form-xdstextinput--default

With Description

Screenshot:

With Description

View in Storybook · form-xdstextinput--with-description

With Hidden Label

Screenshot:

With Hidden Label

View in Storybook · form-xdstextinput--with-hidden-label

With Value

Screenshot:

With Value

View in Storybook · form-xdstextinput--with-value

All Variations

Screenshot:

All Variations

View in Storybook · form-xdstextinput--all-variations

Optional Field

Screenshot:

Optional Field

View in Storybook · form-xdstextinput--optional-field

Required Field

Screenshot:

Required Field

View in Storybook · form-xdstextinput--required-field

Description With Optional

Screenshot:

Description With Optional

View in Storybook · form-xdstextinput--description-with-optional

Disabled

Screenshot:

Disabled

View in Storybook · form-xdstextinput--disabled

With Start Icon

Screenshot:

With Start Icon

View in Storybook · form-xdstextinput--with-start-icon

With Start Icon And Small Size

Screenshot:

With Start Icon And Small Size

View in Storybook · form-xdstextinput--with-start-icon-and-small-size

Size Variants

Screenshot:

Size Variants

View in Storybook · form-xdstextinput--size-variants

Start Icon Variations

Screenshot:

Start Icon Variations

View in Storybook · form-xdstextinput--start-icon-variations

Error Status

Screenshot:

Error Status

View in Storybook · form-xdstextinput--error-status

Warning Status

Screenshot:

Warning Status

View in Storybook · form-xdstextinput--warning-status

Success Status

Screenshot:

Success Status

View in Storybook · form-xdstextinput--success-status

Status Without Message

Screenshot:

Status Without Message

View in Storybook · form-xdstextinput--status-without-message

Status Variations

Screenshot:

Status Variations

View in Storybook · form-xdstextinput--status-variations

With Tooltip

Screenshot:

With Tooltip

View in Storybook · form-xdstextinput--with-tooltip

Tooltip With Optional

Screenshot:

Tooltip With Optional

View in Storybook · form-xdstextinput--tooltip-with-optional

XDSTimeInput

Default

Screenshot:

Default

Interaction Preview: (view video)

Default interaction

View in Storybook · form-xdstimeinput--default

With Value

Screenshot:

With Value

View in Storybook · form-xdstimeinput--with-value

Twenty Four Hour Format

Screenshot:

Twenty Four Hour Format

View in Storybook · form-xdstimeinput--twenty-four-hour-format

With Seconds

Screenshot:

With Seconds

View in Storybook · form-xdstimeinput--with-seconds

With Clear Button

Screenshot:

With Clear Button

View in Storybook · form-xdstimeinput--with-clear-button

With Description

Screenshot:

With Description

View in Storybook · form-xdstimeinput--with-description

With Min Max

Screenshot:

With Min Max

View in Storybook · form-xdstimeinput--with-min-max

With Increment

Screenshot:

With Increment

View in Storybook · form-xdstimeinput--with-increment

Optional

Screenshot:

Optional

View in Storybook · form-xdstimeinput--optional

Required

Screenshot:

Required

View in Storybook · form-xdstimeinput--required

Disabled

Screenshot:

Disabled

View in Storybook · form-xdstimeinput--disabled

Small Size

Screenshot:

Small Size

View in Storybook · form-xdstimeinput--small-size

With Error Status

Screenshot:

With Error Status

View in Storybook · form-xdstimeinput--with-error-status

With Warning Status

Screenshot:

With Warning Status

View in Storybook · form-xdstimeinput--with-warning-status

With Success Status

Screenshot:

With Success Status

View in Storybook · form-xdstimeinput--with-success-status

All Variations

Screenshot:

All Variations

View in Storybook · form-xdstimeinput--all-variations


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

cixzhang added a commit that referenced this pull request Feb 24, 2026
Add interactive stories demonstrating the async action pattern
for all affected components:

- Button: AsyncAction, AsyncActionVariants
- TextInput: AsyncSave, AsyncValidation, ManualLoading
- TextArea: AsyncAutoSave
- CheckboxInput: AsyncToggle, AsyncWithValidation
- Switch: AsyncToggle, AsyncSettingsPanel
- Selector: AsyncSelection
- DateInput: AsyncDateChange
- TimeInput: AsyncTimeChange

Each story uses a simulated delay to show the loading state
and optimistic update behavior in action.

Part of #146
@cixzhang

Copy link
Copy Markdown
Contributor Author

Added storybook examples for all the new action props on branch navi/feat/action-stories — can be cherry-picked or merged into this PR.

Stories added (14 total):

Component Stories
Button AsyncAction — save with status feedback, AsyncActionVariants — all 4 variants
TextInput AsyncSave — basic auto-save, AsyncValidation — onChange gates onChangeAction with preventDefault, ManualLoading — static isLoading
TextArea AsyncAutoSave — auto-save with saved indicator
CheckboxInput AsyncToggle — server-persisted toggle, AsyncWithValidation — terms acceptance with validation
Switch AsyncToggle — single setting, AsyncSettingsPanel — realistic settings page with 3 switches
Selector AsyncSelection — region migration with status
DateInput AsyncDateChange — date picker with save indicator
TimeInput AsyncTimeChange — time picker with save indicator

All use simulated delays so you can see the loading spinners and optimistic updates in action. 959 tests passing, storybook builds clean.

@cixzhang
cixzhang merged commit b8ef662 into main Feb 24, 2026
9 checks passed
@cixzhang
cixzhang deleted the react-transitions-v2 branch February 25, 2026 07:02
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant