Skip to content

refactor(reorder): the controller reads a collection's rows through a reader - #11199

Merged
cixzhang merged 2 commits into
mainfrom
l0/reorder-controller-rows-reader
Nov 11, 2026
Merged

cixzhang merged 2 commits into
mainfrom
l0/reorder-controller-rows-reader

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This is step 1 of 3 toward spec:AST-103 FR4b (attach), which makes plain elements reorderable without React; RichText's block move builds on it. It is a refactor with no behavior change.

ListReorderController found a collection's rows by assuming they are the list element's direct children: eleven ordered reads, rowOf, and two checks in a commit. It now finds them through an internal rows source, ReorderRows {read(container), holds(element, container)}. Its default, CHILD_ROWS, is the old rowsOf read and the old direct-child test, and List passes no other source, so every List keeps its behavior exactly. FR4b's attach (step 2) will pass a source built from its items(), whose rows need not be direct children.

  • listReorderContext.ts: the ReorderRows type; ListReorderEngine.createSession takes an optional source.
  • listReorderEngine.tsx: the controller takes the source (default CHILD_ROWS). The ordered reads use read; rowOf and the commit's row checks use holds.
  • component:List: its spec:AST-103 relation names the rows reader, as Specs ruled. The attach clause waits for step 2.
  • A [chore] Internal Changeset, because Core source changes.

No public API or rendering change.

Evidence

  • vitest run packages/core/src/List packages/core/src/reorderable packages/core/src/TransferList packages/core/src/ListInput: 195 passed, all of List's reorder suites unchanged.
  • Core tsc and eslint.
  • The real-browser reorder specs (pointer, mode, touch) run in CI unchanged.

Writing rubric results

Run over the List.spec.md sentence.

  • R1 narration: none.
  • R2 research in the record: none.
  • R3 evidence naming a change: none.
  • R4 rejected alternatives over one line or outside a decision: none.
  • R5 pull request or issue references remaining: none.
  • R6 ruled open questions still listing options: none.
  • R7 project status in the record: none.

(Posted by Cindy's agent on her behalf.)

… reader

ListReorderController took its rows from the list element's children in
eleven places. It now reads them through a rows(container) reader, which
defaults to the element children, so List's behavior is unchanged. This
lets AST-103 FR4b's attach drive a plain container. component:List names
the reader.
@vercel

vercel Bot commented Nov 11, 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 11, 2026 9:59am UTC

Request Review

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

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 11, 2026, 11:02 AM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec ffc6389

@cixzhang cixzhang added ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) labels Nov 11, 2026

@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.

Requesting changes: the refactor keeps List's reorder behavior unchanged and adds no public API, but the required lint check fails on this head.

Blocking

  • The @astryxdesign/core source changes in listReorderEngine.tsx and listReorderContext.ts ship without a Changeset, so Check Changeset coverage fails in the required lint job; add a .changeset/*.md with '@astryxdesign/core': patch and a [chore] Internal: … line, as earlier internal Core refactors do.

Non-blocking

  • readRows covers the ordered-row reads, but rowOf and the parentElement === list checks still assume rows are the container's direct children; route them through the reader, or state that constraint in its JSDoc, before attach passes its own reader.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 11, 2026 09:43
@cixzhang
cixzhang marked this pull request as ready for review November 11, 2026 09:43
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 1f44bfe

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
CheckboxList 71.5 kB (0) · 7.8 kB CSS (0) — — · — · —
ContextMenu 112.1 kB (0) · 17.5 kB CSS (0) — — · — · —
DropdownMenu 101.0 kB (0) · 17.6 kB CSS (0) — — · — · —
14 more components
Component Size LoC Visual · A11y · RTL
List 18.9 kB (0) · 790 B CSS (0) — ✓ · ✓ · —
ListItem 73.2 kB (0) · 11.5 kB CSS (0) — ✓ · ✓ · ✓
Markdown 192.3 kB (0) · 20.8 kB CSS (0) — — · — · —
MoreMenu 101.3 kB (0) · 17.6 kB CSS (0) — — · — · —
PowerSearch 296.3 kB (0) · 24.5 kB CSS (0) — — · — · —
Table 129.3 kB (0) · 18.4 kB CSS (0) — — · — · —
TableCell 113.4 kB (0) · 18.0 kB CSS (0) — — · — · —
TableHeaderCell 112.9 kB (0) · 17.7 kB CSS (0) — — · — · —
lab/Comments 357.6 kB (0) · 2.5 kB CSS (0) — — · — · —
lab/CommentThread 350.7 kB (0) · 2.4 kB CSS (0) — — · — · —
lab/ListInput 91.2 kB (0) · 922 B CSS (0) — — · — · —
lab/TabBarMoreList 95.6 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/TransferList 105.3 kB (0) · 1.2 kB CSS (0) — — · — · —
lab/TransferListSelector 114.0 kB (0) · 1.4 kB CSS (0) — — · — · —

Package size: @astryxdesign/core 7.33 MB packed (+560 B); no new dependencies.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

…ows reader; add the internal changeset

The reader becomes a rows source: read lists the rows in order, and
holds tells whether an element is a row. rowOf and the two
parentElement checks in a commit use holds, whose default is the old
direct-child test, so List is unchanged. A [chore] Internal changeset
covers the core source change.
@cixzhang
cixzhang marked this pull request as draft November 11, 2026 09:51
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 11, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 1f44bfe

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 11, 2026

@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.

Approved pending CI: some required test jobs are still running on this head.

The rows source keeps List's reorder behaviour unchanged (the default CHILD_ROWS is the old rowsOf read and direct-child test) and adds no public API, and the component:List sentence carries an engineering owner's spec approval for this head.

Non-blocking

  • The comments on CHILD_ROWS and on the rows constructor parameter in listReorderEngine.tsx restate the name, the ReorderRows type and the default, which rowsOf and createSession already document; consider dropping them.
  • The description's test command names packages/core/src/TransferList and packages/core/src/ListInput, which do not exist (those suites live under packages/lab/src); please correct the paths so the evidence says what ran.

Automated review (maintainer link)

);
}

/** A List's rows: its element children. */

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.

Non-blocking (INV29): this comment restates the name CHILD_ROWS; rowsOf and createSession already say a List's rows are its element children. Consider dropping it.

constructor(
private readonly getList: () => HTMLElement | null,
readonly hintId: string,
/** Finds the collection's rows. A List's rows are its element children. */

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.

Non-blocking (INV29): this restates the ReorderRows type and the CHILD_ROWS default. Consider dropping it; the type's JSDoc and createSession's already carry the fact.

@cixzhang
cixzhang marked this pull request as ready for review November 11, 2026 10:44
@cixzhang
cixzhang merged commit 36bf4fc into main Nov 11, 2026
129 checks passed
@github-actions
github-actions Bot deleted the l0/reorder-controller-rows-reader branch November 12, 2026 06:06
cixzhang pushed a commit that referenced this pull request Nov 12, 2026
…10815)

* refactor(List): write the reorder refs at commit, not in render

Conformance tidy, no visible change. The reorder session's list getter
and the mode hint's layer handle were copied into refs during render.
Each is now written in a one-line layout effect, so a render React
discards leaves nothing behind. No failure is reachable today. Every
list getter returns the same element. The layer ref's only reader is
the hint's layout effect. It reads the ref at the commit, right after
the committed render wrote it. The cleanup uses the handle it captured.

* fix(List): a reorder handle's name follows its row's place and label

A reorder handle named itself from the DOM in a passive effect: after
Item's label element when that element shows a name, else after the
row's place ("Reorder item N"). The effect ran only when the handle
rendered. A memoized row whose place changed, because a row above it
went or the rows reordered, kept the old place in its handle's name. A
label that gained or lost its text through its own state left the
handle named the old way.

The reorder session now reads both from the DOM, outside React. It
registers the list's rows and its handles' label elements with Core's
shared mutation observer, and releases them with the list. It keeps
each handle's label naming, and the place only for a handle named after
it. The handle reads them through useSyncExternalStore, as it reads
reorder mode, and renders its name from them. Only a change renders
the handle again, so its passive effect is gone. A row named after its
place still warns in development, once, from the session. positionOf
loses its last caller and goes.

The session follows the list element the List renders, which changes
when its numbering turns on or off.

ListReorderNames.test.tsx covers a row above that goes, a reorder, and
a label that gains and loses text: each fails on main and passes here.
A reorder after the numbering turns on passes on both.

* Merge main 1740654 into the reorder handle names

Main brings in #11199, whose controller reads a collection's rows
through a reader, and #11352's committed-ref hook. #11199 edits
positionOf, which this branch removes; it stays removed. One hand edit:
refreshNames reads this.rows.read(list) instead of rowsOf(list), as
#11199's positionOf did, so a collection's own reader numbers its rows.

* refactor(List): the reorder refs use the committed-ref hook

The session's list getter and the mode hint's layer handle were each
copied into a ref by a one-line layout effect. They now use Core's
useCommittedRef, which writes them in a commit-phase insertion effect.
The session's useMemo lists the stable getter ref in its dependencies.

No behavior changes. Every getter List passes reads the same list ref
when called, and the hint's effect reads the handle after either
write. A handle's cleanup can reach the getter through release(), and
gets the same list. The hint's cleanup hides the handle its setup
showed, so no cleanup reads the layer ref.

* fix(List): an unchanged handle name keeps its snapshot

The names refresh compared each handle's name with the session's own
entry, which a handle named some other way has none of before the
first read. So it stored a new {position: null, labelNamesRow: null}
and the handle rendered again with the same name on every mount
(architecture:react-component-runtime INV9). It now compares with
handleNameOf, whose shared unread name has the same fields.

A test counts the handle's renders through the verb it reads each
render: once per handle on mount, and once for a row that mounts later.

* fix(List): a hydrated handle keeps its server snapshot

The handle's server snapshot was its own unread name, and the session
answered an unread handle with another object with the same fields.
So after hydration React saw a new snapshot, and each handle rendered
again with the same name (architecture:react-component-runtime INV9).
The handle now exports one unread name, and the session answers with
it.

A test hydrates server markup and counts the handle's renders through
the verb it reads each render: once per handle.

* fix(List): a label that names its row keeps the unread snapshot

The names refresh stored whether Item's label element names the row:
null before the first read, and true after it, though the handle and
the session read both alike. So a handle named by its row's text label
rendered again with the same name after mounting and after hydrating
(architecture:react-component-runtime INV9). The snapshot now records
whether the label shows no name, which stays false until a read finds
the label blank.

Both render-count cases add a row named by its text label.

* Merge main 06b7e61 into the reorder handle names

Main brings in #10912, which changes Layer/useLayer.tsx, the layer the
mode hint shows. The merge needs no hand edit.

* Merge main 31aacff into the reorder handle names

Main brings in #11336, which changes List/ListItem.tsx, the row that
renders the reorder handle. The merge needs no hand edit.

This branch was successfully deployed

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

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) 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