Skip to content

feat(lab): add ListInput - #4740

Merged
ernestt merged 4 commits into
mainfrom
codex/list-input-lab
Aug 7, 2026
Merged

ernestt merged 4 commits into
mainfrom
codex/list-input-lab

Conversation

@ernestt

@ernestt ernestt commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add ListInput to @astryxdesign/lab for short, consistent collections such as guest lists, traveler details, mailing lists, and tag options.
  • Keep collection state controlled while the component owns layout, add/remove actions, focus management, validation placement, collection motion, and accessible reordering.
  • Document the intended range: normally fewer than seven records and no more than three simple fields per record.

Closes #4531.

Early API arbitration

The initial vibe test compared three API models across six scenarios: guest list entry, traveler review, three-scope tag validation, dialog-based contacts, a narrow mailing list, and migration from repeated field pairs. Full context is in RFC #4531.

Candidate Result
Data-driven ListInput 38/40
Compound EditableList 33/40
Render-prop FieldArray 16/40

The typed-column ListInput model was the shortest and most reusable while preserving component-owned interaction and accessibility. The compound model added ceremony, while the render-prop model encouraged consumers to rebuild row semantics and controls.

Design review then refined that winning direction:

  • Minimum-count validation remains caller-owned through status; maxItems is the physical limit.
  • Read-only rendering and renderValue are deferred until there is a validated use case.
  • Field validation timing remains caller-owned, so new rows do not appear invalid before blur.
  • The final presentation uses component-owned primary-tone labels without table chrome, native input status tooltips, medium-density controls, and a 640px container stacking threshold.
  • Pointer activation measures the stable Add row before pointer-down blur or validation can change layout, then preserves that viewport position through available nested scroll containers. A single next-frame verification catches late browser anchoring without a persistent scroll/resize observer. Keyboard activation keeps the normal focus flow, and a meaningfully hidden focused field still takes priority.
  • Reordering uses a handle-only pointer/keyboard interaction, a free-moving 50%-opacity drag preview in Astryx's top-layer system, a stable insertion line, and one tokenized commit animation on release.

The drag treatment follows the public Design Conventions reorder contract: 50% opacity is a temporary active-drag exception and normal contrast returns immediately on drop or cancel.

What changed

  • Add the generic controlled ListInput<T> API and typed column/render contexts.
  • Forward complete field status plus statusVariant="tooltip" to rendered Astryx inputs, preserving native semantics without changing row height.
  • Support add, remove, pointer/touch reorder, keyboard reorder, cancellation, announcements, and predictable focus restoration.
  • Use medium sizing consistently across consumer inputs, Add, remove, reorder controls, and their layout tracks so validation affordances do not cause height mismatches.
  • Add tokenized live add/remove motion without delaying controlled changes, focus handoff, or announcements; reduced-motion preferences and unsupported browsers remain instant.
  • Keep the Add action under the pointer during repeated entry, including blur-driven validation, nested or partially clamped scroll containers, and a late browser adjustment on the following frame. The work runs only during Add activation and installs no ongoing observer or scroll listener.
  • Preserve nested theme variables in the drag preview through useLayer, remove the magic z-index, and use Astryx motion tokens for committed reorder motion.
  • Add proportional/fixed column sizing and component-owned stacking at 640px, with 32px between responsive record groups and row actions aligned beside the first field.
  • Add one-, two-, and three-field Storybook scenarios, including empty, non-reorderable, responsive stress, validation, and mixed-control examples.
  • Add component docs and 19 focused behavior/accessibility tests.

Screenshot

ListInput tag-options example

Risk

The component is isolated to the experimental Labs package and canary environment. No Core API is changed.

Testing

  • pnpm -F @astryxdesign/lab build
  • pnpm -F @astryxdesign/storybook typecheck
  • pnpm -F @astryxdesign/lab test packages/lab/src/ListInput/ListInput.test.tsx — 19 tests
  • pnpm -F @astryxdesign/lab typecheck:docs
  • ESLint and Prettier on the changed files
  • Repository pre-commit sync, package-boundary, changeset, media, executable-bit, and CLI-structure checks
  • Explicit internal-reference leak scan on the complete pending diff

@vercel

vercel Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 6, 2026 11:30pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 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.

New Components

ListInput (@astryxdesign/lab) · View in Storybook
Metric Value
Bundle Size (ESM) N/A
Bundle Size (CJS) 415B
Lines of Code 1649
Source Files 2
Complexity Very High (266)
Exports ListInput
Props Count N/A
Has Tests Yes
Has Stories Yes

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/lab N/A 3.7KB 1.6KB

Accessibility Audit

Status: No accessibility violations detected.


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

github-actions Bot added a commit that referenced this pull request Aug 6, 2026
github-actions Bot added a commit that referenced this pull request Aug 7, 2026
@ernestt
ernestt merged commit 6cc7798 into main Aug 7, 2026
19 checks passed
@github-actions
github-actions Bot deleted the codex/list-input-lab branch August 8, 2026 06:25
cixzhang added a commit that referenced this pull request Aug 12, 2026
…ets guard

MoreMenu hand-assembled its `astryx-more-menu` theme target with
`stableClassName()` and string concatenation. Route it through
`themeProps()`/`mergeProps()` instead, so the target sits on the same
reflection surface as every other one. The rendered DOM is unchanged.

themingTargets.test.ts grows the second direction of the guard —
documented targets must actually be rendered — and scans both
`@astryxdesign/core` and `@astryxdesign/lab` package-wide for the
`docs` block. `docsZh` stays a per-directory check.

Rebased onto main, which moved 69 commits under it:

- `themeProps()` gained a third `options.legacyNames` argument
  (#4712, #4890) for targets renamed behind a deprecation window. The
  extractor only read the first two arguments, so `astryx-checkbox`,
  `astryx-radio` and `astryx-radio-dot` — emitted through
  `legacyNames` and deliberately documented with `deprecatedFor` —
  looked unrendered. Teach it to read `legacyNames` string literals as
  rendered sites of their own, with the same prop keys (they land on the
  same element), and cover it with two extractor tests.
- ListInput (#4740) and TransferList (#4870) landed after this branch
  was cut and render five undocumented targets between them. Document
  them, the same way the other lab components here are documented.
- Stepper's targets were extended on main with the same
  `indicatorPosition` entry this branch added, plus
  `astryx-step-indicator` and the matching `docsZh` block; kept
  main's superset. Both sides' new MoreMenu tests are kept.
cixzhang added a commit that referenced this pull request Aug 12, 2026
… scope

pr-a11y audits the components a PR touches. This PR touches only
`*.doc.mjs` metadata for these components — Storybook never reads
`.doc.mjs` — so it renders nothing differently; it just widens the
audit's scope onto violations that were already there.

Each entry was verified by auditing the story at unmodified
`origin/main` and reproducing it:

- `RichTextEditor::With Links` / `With Auto Link` —
  `aria-input-field-name`. The Lexical `role="textbox"` host has no
  accessible name in ALL 14 RichTextEditor stories; twelve of them are
  already baselined. These two arrived with link support (#4670,
  2026-08-04) after the baseline snapshot was generated (2026-07-31),
  which is the only reason they are missing.
- `Schedule::List` — `color-contrast`. Schedule's stories anchor their
  events to `new Date()`, and past events render dimmed (#a9a9a9 on
  #ffffff, 2.35:1). Whether a given view contains a past event depends
  on the wall-clock time of the run, so the violation moves between
  stories: with the clock pinned to the failing CI run's date it
  reproduces on `List` at unmodified main; pinned to today it does not.
  Its five sibling Schedule stories are already baselined for the same
  rule.
- `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts
  `aria-required` on a `role="group"` element, which does not support
  it. ListInput landed (#4740) after the baseline snapshot and has
  never been gated. NEEDS A REAL FIX in its own PR: Slider and
  FileInput already work around the same restriction (see the comments
  at Slider.tsx:452 and FileInput.tsx:472), and picking between those
  remedies is a call for ListInput's owner, not this chore.

Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every
entry for the components it audits, which would have dropped the
Schedule, LogStream and Chat contrast entries that happen not to
reproduce on this machine today.

@cixzhang
cixzhang added a commit that referenced this pull request Aug 12, 2026
…ets guard

MoreMenu hand-assembled its `astryx-more-menu` theme target with
`stableClassName()` and string concatenation. Route it through
`themeProps()`/`mergeProps()` instead, so the target sits on the same
reflection surface as every other one. The rendered DOM is unchanged.

themingTargets.test.ts grows the second direction of the guard —
documented targets must actually be rendered — and scans both
`@astryxdesign/core` and `@astryxdesign/lab` package-wide for the
`docs` block. `docsZh` stays a per-directory check.

Rebased onto main, which moved 69 commits under it:

- `themeProps()` gained a third `options.legacyNames` argument
  (#4712, #4890) for targets renamed behind a deprecation window. The
  extractor only read the first two arguments, so `astryx-checkbox`,
  `astryx-radio` and `astryx-radio-dot` — emitted through
  `legacyNames` and deliberately documented with `deprecatedFor` —
  looked unrendered. Teach it to read `legacyNames` string literals as
  rendered sites of their own, with the same prop keys (they land on the
  same element), and cover it with two extractor tests.
- ListInput (#4740) and TransferList (#4870) landed after this branch
  was cut and render five undocumented targets between them. Document
  them, the same way the other lab components here are documented.
- Stepper's targets were extended on main with the same
  `indicatorPosition` entry this branch added, plus
  `astryx-step-indicator` and the matching `docsZh` block; kept
  main's superset. Both sides' new MoreMenu tests are kept.
cixzhang added a commit that referenced this pull request Aug 12, 2026
… scope

pr-a11y audits the components a PR touches. This PR touches only
`*.doc.mjs` metadata for these components — Storybook never reads
`.doc.mjs` — so it renders nothing differently; it just widens the
audit's scope onto violations that were already there.

Each entry was verified by auditing the story at unmodified
`origin/main` and reproducing it:

- `RichTextEditor::With Links` / `With Auto Link` —
  `aria-input-field-name`. The Lexical `role="textbox"` host has no
  accessible name in ALL 14 RichTextEditor stories; twelve of them are
  already baselined. These two arrived with link support (#4670,
  2026-08-04) after the baseline snapshot was generated (2026-07-31),
  which is the only reason they are missing.
- `Schedule::List` — `color-contrast`. Schedule's stories anchor their
  events to `new Date()`, and past events render dimmed (#a9a9a9 on
  #ffffff, 2.35:1). Whether a given view contains a past event depends
  on the wall-clock time of the run, so the violation moves between
  stories: with the clock pinned to the failing CI run's date it
  reproduces on `List` at unmodified main; pinned to today it does not.
  Its five sibling Schedule stories are already baselined for the same
  rule.
- `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts
  `aria-required` on a `role="group"` element, which does not support
  it. ListInput landed (#4740) after the baseline snapshot and has
  never been gated. NEEDS A REAL FIX in its own PR: Slider and
  FileInput already work around the same restriction (see the comments
  at Slider.tsx:452 and FileInput.tsx:472), and picking between those
  remedies is a call for ListInput's owner, not this chore.

Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every
entry for the components it audits, which would have dropped the
Schedule, LogStream and Chat contrast entries that happen not to
reproduce on this machine today.

@cixzhang
cixzhang added a commit that referenced this pull request Aug 14, 2026
…ets guard

MoreMenu hand-assembled its `astryx-more-menu` theme target with
`stableClassName()` and string concatenation. Route it through
`themeProps()`/`mergeProps()` instead, so the target sits on the same
reflection surface as every other one. The rendered DOM is unchanged.

themingTargets.test.ts grows the second direction of the guard —
documented targets must actually be rendered — and scans both
`@astryxdesign/core` and `@astryxdesign/lab` package-wide for the
`docs` block. `docsZh` stays a per-directory check.

Rebased onto main, which moved 69 commits under it:

- `themeProps()` gained a third `options.legacyNames` argument
  (#4712, #4890) for targets renamed behind a deprecation window. The
  extractor only read the first two arguments, so `astryx-checkbox`,
  `astryx-radio` and `astryx-radio-dot` — emitted through
  `legacyNames` and deliberately documented with `deprecatedFor` —
  looked unrendered. Teach it to read `legacyNames` string literals as
  rendered sites of their own, with the same prop keys (they land on the
  same element), and cover it with two extractor tests.
- ListInput (#4740) and TransferList (#4870) landed after this branch
  was cut and render five undocumented targets between them. Document
  them, the same way the other lab components here are documented.
- Stepper's targets were extended on main with the same
  `indicatorPosition` entry this branch added, plus
  `astryx-step-indicator` and the matching `docsZh` block; kept
  main's superset. Both sides' new MoreMenu tests are kept.
cixzhang added a commit that referenced this pull request Aug 14, 2026
…ets guard

MoreMenu hand-assembled its `astryx-more-menu` theme target with
`stableClassName()` and string concatenation. Route it through
`themeProps()`/`mergeProps()` instead, so the target sits on the same
reflection surface as every other one. The rendered DOM is unchanged.

themingTargets.test.ts grows the second direction of the guard —
documented targets must actually be rendered — and scans both
`@astryxdesign/core` and `@astryxdesign/lab` package-wide for the
`docs` block. `docsZh` stays a per-directory check.

Rebased onto main, which moved 69 commits under it:

- `themeProps()` gained a third `options.legacyNames` argument
  (#4712, #4890) for targets renamed behind a deprecation window. The
  extractor only read the first two arguments, so `astryx-checkbox`,
  `astryx-radio` and `astryx-radio-dot` — emitted through
  `legacyNames` and deliberately documented with `deprecatedFor` —
  looked unrendered. Teach it to read `legacyNames` string literals as
  rendered sites of their own, with the same prop keys (they land on the
  same element), and cover it with two extractor tests.
- ListInput (#4740) and TransferList (#4870) landed after this branch
  was cut and render five undocumented targets between them. Document
  them, the same way the other lab components here are documented.
- Stepper's targets were extended on main with the same
  `indicatorPosition` entry this branch added, plus
  `astryx-step-indicator` and the matching `docsZh` block; kept
  main's superset. Both sides' new MoreMenu tests are kept.
cixzhang added a commit that referenced this pull request Aug 14, 2026
… scope

pr-a11y audits the components a PR touches. This PR touches only
`*.doc.mjs` metadata for these components — Storybook never reads
`.doc.mjs` — so it renders nothing differently; it just widens the
audit's scope onto violations that were already there.

Each entry was verified by auditing the story at unmodified
`origin/main` and reproducing it:

- `RichTextEditor::With Links` / `With Auto Link` —
  `aria-input-field-name`. The Lexical `role="textbox"` host has no
  accessible name in ALL 14 RichTextEditor stories; twelve of them are
  already baselined. These two arrived with link support (#4670,
  2026-08-04) after the baseline snapshot was generated (2026-07-31),
  which is the only reason they are missing.
- `Schedule::List` — `color-contrast`. Schedule's stories anchor their
  events to `new Date()`, and past events render dimmed (#a9a9a9 on
  #ffffff, 2.35:1). Whether a given view contains a past event depends
  on the wall-clock time of the run, so the violation moves between
  stories: with the clock pinned to the failing CI run's date it
  reproduces on `List` at unmodified main; pinned to today it does not.
  Its five sibling Schedule stories are already baselined for the same
  rule.
- `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts
  `aria-required` on a `role="group"` element, which does not support
  it. ListInput landed (#4740) after the baseline snapshot and has
  never been gated. NEEDS A REAL FIX in its own PR: Slider and
  FileInput already work around the same restriction (see the comments
  at Slider.tsx:452 and FileInput.tsx:472), and picking between those
  remedies is a call for ListInput's owner, not this chore.

Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every
entry for the components it audits, which would have dropped the
Schedule, LogStream and Chat contrast entries that happen not to
reproduce on this machine today.

@cixzhang
cixzhang added a commit that referenced this pull request Aug 14, 2026
…ets guard

MoreMenu hand-assembled its `astryx-more-menu` theme target with
`stableClassName()` and string concatenation. Route it through
`themeProps()`/`mergeProps()` instead, so the target sits on the same
reflection surface as every other one. The rendered DOM is unchanged.

themingTargets.test.ts grows the second direction of the guard —
documented targets must actually be rendered — and scans both
`@astryxdesign/core` and `@astryxdesign/lab` package-wide for the
`docs` block. `docsZh` stays a per-directory check.

Rebased onto main, which moved 69 commits under it:

- `themeProps()` gained a third `options.legacyNames` argument
  (#4712, #4890) for targets renamed behind a deprecation window. The
  extractor only read the first two arguments, so `astryx-checkbox`,
  `astryx-radio` and `astryx-radio-dot` — emitted through
  `legacyNames` and deliberately documented with `deprecatedFor` —
  looked unrendered. Teach it to read `legacyNames` string literals as
  rendered sites of their own, with the same prop keys (they land on the
  same element), and cover it with two extractor tests.
- ListInput (#4740) and TransferList (#4870) landed after this branch
  was cut and render five undocumented targets between them. Document
  them, the same way the other lab components here are documented.
- Stepper's targets were extended on main with the same
  `indicatorPosition` entry this branch added, plus
  `astryx-step-indicator` and the matching `docsZh` block; kept
  main's superset. Both sides' new MoreMenu tests are kept.
cixzhang added a commit that referenced this pull request Aug 14, 2026
… scope

pr-a11y audits the components a PR touches. This PR touches only
`*.doc.mjs` metadata for these components — Storybook never reads
`.doc.mjs` — so it renders nothing differently; it just widens the
audit's scope onto violations that were already there.

Each entry was verified by auditing the story at unmodified
`origin/main` and reproducing it:

- `RichTextEditor::With Links` / `With Auto Link` —
  `aria-input-field-name`. The Lexical `role="textbox"` host has no
  accessible name in ALL 14 RichTextEditor stories; twelve of them are
  already baselined. These two arrived with link support (#4670,
  2026-08-04) after the baseline snapshot was generated (2026-07-31),
  which is the only reason they are missing.
- `Schedule::List` — `color-contrast`. Schedule's stories anchor their
  events to `new Date()`, and past events render dimmed (#a9a9a9 on
  #ffffff, 2.35:1). Whether a given view contains a past event depends
  on the wall-clock time of the run, so the violation moves between
  stories: with the clock pinned to the failing CI run's date it
  reproduces on `List` at unmodified main; pinned to today it does not.
  Its five sibling Schedule stories are already baselined for the same
  rule.
- `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts
  `aria-required` on a `role="group"` element, which does not support
  it. ListInput landed (#4740) after the baseline snapshot and has
  never been gated. NEEDS A REAL FIX in its own PR: Slider and
  FileInput already work around the same restriction (see the comments
  at Slider.tsx:452 and FileInput.tsx:472), and picking between those
  remedies is a call for ListInput's owner, not this chore.

Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every
entry for the components it audits, which would have dropped the
Schedule, LogStream and Chat contrast entries that happen not to
reproduce on this machine today.

@cixzhang
cixzhang added a commit that referenced this pull request Aug 25, 2026
…ets guard

MoreMenu hand-assembled its `astryx-more-menu` theme target with
`stableClassName()` and string concatenation. Route it through
`themeProps()`/`mergeProps()` instead, so the target sits on the same
reflection surface as every other one. The rendered DOM is unchanged.

themingTargets.test.ts grows the second direction of the guard —
documented targets must actually be rendered — and scans both
`@astryxdesign/core` and `@astryxdesign/lab` package-wide for the
`docs` block. `docsZh` stays a per-directory check.

Rebased onto main, which moved 69 commits under it:

- `themeProps()` gained a third `options.legacyNames` argument
  (#4712, #4890) for targets renamed behind a deprecation window. The
  extractor only read the first two arguments, so `astryx-checkbox`,
  `astryx-radio` and `astryx-radio-dot` — emitted through
  `legacyNames` and deliberately documented with `deprecatedFor` —
  looked unrendered. Teach it to read `legacyNames` string literals as
  rendered sites of their own, with the same prop keys (they land on the
  same element), and cover it with two extractor tests.
- ListInput (#4740) and TransferList (#4870) landed after this branch
  was cut and render five undocumented targets between them. Document
  them, the same way the other lab components here are documented.
- Stepper's targets were extended on main with the same
  `indicatorPosition` entry this branch added, plus
  `astryx-step-indicator` and the matching `docsZh` block; kept
  main's superset. Both sides' new MoreMenu tests are kept.
cixzhang added a commit that referenced this pull request Aug 25, 2026
… scope

pr-a11y audits the components a PR touches. This PR touches only
`*.doc.mjs` metadata for these components — Storybook never reads
`.doc.mjs` — so it renders nothing differently; it just widens the
audit's scope onto violations that were already there.

Each entry was verified by auditing the story at unmodified
`origin/main` and reproducing it:

- `RichTextEditor::With Links` / `With Auto Link` —
  `aria-input-field-name`. The Lexical `role="textbox"` host has no
  accessible name in ALL 14 RichTextEditor stories; twelve of them are
  already baselined. These two arrived with link support (#4670,
  2026-08-04) after the baseline snapshot was generated (2026-07-31),
  which is the only reason they are missing.
- `Schedule::List` — `color-contrast`. Schedule's stories anchor their
  events to `new Date()`, and past events render dimmed (#a9a9a9 on
  #ffffff, 2.35:1). Whether a given view contains a past event depends
  on the wall-clock time of the run, so the violation moves between
  stories: with the clock pinned to the failing CI run's date it
  reproduces on `List` at unmodified main; pinned to today it does not.
  Its five sibling Schedule stories are already baselined for the same
  rule.
- `ListInput::*` (5 stories) — `aria-allowed-attr`. ListInput puts
  `aria-required` on a `role="group"` element, which does not support
  it. ListInput landed (#4740) after the baseline snapshot and has
  never been gated. NEEDS A REAL FIX in its own PR: Slider and
  FileInput already work around the same restriction (see the comments
  at Slider.tsx:452 and FileInput.tsx:472), and picking between those
  remedies is a call for ListInput's owner, not this chore.

Hand-added rather than regenerated: `pnpm a11y:baseline` rewrites every
entry for the components it audits, which would have dropped the
Schedule, LogStream and Chat contrast entries that happen not to
reproduce on this machine today.

@cixzhang
yyq1025 added a commit to yyq1025/astryx that referenced this pull request Sep 4, 2026
Every revision so far inferred whether a scroll was the reader's from
the gesture that preceded it, and every inference has a counterexample:
a bubbled touchstart, a nested scroller at its edge, then one with
`overscroll-behavior: contain`. The question was never who owns the
gesture. It is what can move a following container up other than the
reader, and there are two answers: the resize clamp onto the bottom,
and CSS scroll anchoring.

The clamp lands exactly on the bottom, which the guard already checks.
Anchoring is switched off on the scroll element while following and
restored when not — the hook is the only writer of the position while
locked, so anchoring has nothing to do there, and a reader up in the
history keeps it. With that, any upward scroll that does not land on
the bottom is the reader, and the wheel and touch listeners, the
gesture waiver, the two-frame expiry, and the synthetic-resize tracking
all go. Same shape as ListInput (meta#4740) and LegendList's
maintainVisibleContentPosition, for the same reason.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
cixzhang pushed a commit that referenced this pull request Sep 4, 2026
)

* fix(chat): gestures vouch for their scroll instead of unlocking (#5662)

`onWheel` and `onTouchMove` gated on `animatingRef`, which has meant "we
are following" only by coincidence. #4104 added a reduced-motion path
that follows without ever starting a spring, so both handlers became
permanent no-ops for readers with reduced motion, and the remaining
release path — `onScroll`'s direction check — is blind exactly when it
matters, since arriving content changes the geometry on nearly every
event.

Restores the arbitration this hook was extracted from (#1249): the
gesture does not unlock, it clears the suppression so the scroll it
produces is read as intent. Here that means waiving the synthetic-resize
guard for the frames the gesture covers and letting the direction check
decide. A gesture this scroller never consumed — a wheel over a nested
scrollable child, an overscroll at the bottom — produces no scroll event
and now leaves following alone, where before it released the tail
whenever the spring was live. `touchstart` replaces `touchmove` for the
reason it was the original listener: it fires once, before any movement,
and needs no per-drag bookkeeping.

`jumpToBottom` (#3800) also cleared `animatingRef` while `lockedRef`
stayed true, which no other caller did, so a running loop survived its
own cancellation and the next `startAnimation` stacked a second one on
top (#5663). A generation token makes the documented cancel real; with
the gesture handlers off `animatingRef`, it is loop bookkeeping again.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(chat): a resize clamp landing on the bottom is never a release

A finger resting on a nested scrollable child bubbles `touchstart` to
the chat scroller, so the gesture waiver was live for a drag this
scroller never consumed. If an earlier block collapsed while the finger
was down, the browser clamped `scrollTop` up to the new bottom and the
waived guard read that clamp as the reader scrolling: following
released, and the lines streamed next stayed below the fold. The wheel
waiver had the same hole, two frames wide.

A clamp can only ever land on the new maximum, and a reader scrolling
up never lands there. So a scroll that arrives with changed geometry
and ends at the bottom is the clamp regardless of any gesture, and the
guard now keeps it synthetic. The waiver still lets a real scroll-up
through while content is arriving, which is what it was for.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* refactor(chat): cancel the spring's frame instead of tagging generations

The loop's continuation is always one pending rAF handle, and
`jumpToBottom` only ever runs from an event or another frame callback,
so `cancelAnimationFrame` on that handle is an exact cancel — the same
`rafRef` shape `useChatDictation` and `useSpeechRecognition` use.
`animate` goes back to taking no argument, and the generation counter,
its per-frame closure, and the check at the top of the tick are gone.

The test double now hands out real ids and honours cancellation, so the
stacked-loop test keeps proving the same thing. Comments around the
synthetic-resize guard and the wheel waiver are folded down to what the
code no longer says on its own.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(chat): only a gesture this scroller consumes waives the guard

A bubbled gesture was treated as ownership of every scroll that
followed. With the spring trailing a fast stream, a finger resting on a
nested scroller plus a collapse above the viewport moved scrollTop up
by scroll anchoring — not a clamp, so it did not land on the bottom —
and the waived guard read the shift as the reader. Following released.

Ownership now comes from the gesture itself. A wheel up vouches only
when no vertically scrollable element between its target and this
scroller still has room above; scroll chaining hands a gesture outward
only from a scroller at its edge. A drag records its target and finger
position on touchstart and vouches from the first touchmove that pushes
this scroller up, under the same nested check, until the finger lifts.
A resting finger is not a gesture. The bottom-landing rule stays for the
one clamp a consumed gesture can still coincide with: an overscroll at
the bottom while a block above collapses.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(chat): own the position while following instead of judging gestures

Every revision so far inferred whether a scroll was the reader's from
the gesture that preceded it, and every inference has a counterexample:
a bubbled touchstart, a nested scroller at its edge, then one with
`overscroll-behavior: contain`. The question was never who owns the
gesture. It is what can move a following container up other than the
reader, and there are two answers: the resize clamp onto the bottom,
and CSS scroll anchoring.

The clamp lands exactly on the bottom, which the guard already checks.
Anchoring is switched off on the scroll element while following and
restored when not — the hook is the only writer of the position while
locked, so anchoring has nothing to do there, and a reader up in the
history keeps it. With that, any upward scroll that does not land on
the bottom is the reader, and the wheel and touch listeners, the
gesture waiver, the two-frame expiry, and the synthetic-resize tracking
all go. Same shape as ListInput (#4740) and LegendList's
maintainVisibleContentPosition, for the same reason.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(chat): hand back the scroll element's own overflow-anchor

Unlocking wrote '' over whatever inline overflow-anchor the consumer had
set, so a scroller that had disabled anchoring itself got it back once
the reader scrolled up. Capture the element's inline value when the
hook takes it over and restore that value on unlock and on cleanup.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(chat): judge a scroll against the hook's own last write

Two ownership gaps from review. A reader's wheel that lands between two
spring frames was compared against the last observed position, and the
next frame's write outran it — net position still advanced, so the
reader stayed pinned. The spring now records the position it wrote, so
the coalesced scroll event that follows reads below it and releases;
the same comparison use-stick-to-bottom makes against the position it
set (`ignoreScrollToTop`).

And the anchoring switch no longer goes through the element's inline
style at all. It is an attribute, `data-astryx-chat-following`, and one
injected rule with `!important`, the pattern `highlightRanges` uses for
its dynamic stylesheet. A consumer's own `overflow-anchor` is never read,
written or restored — whatever they set, before or during a lock, is
what applies once the attribute is gone.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 605d07a6 Deployed Aug 6, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] ListInput — compact editor for small repeated records

1 participant