Skip to content

feat(lab): reorder Table columns by keyboard and by taps - #14018

Open
humbertovirtudes wants to merge 2 commits into
mainfrom
feat/lab-table-drag-columns
Open

humbertovirtudes wants to merge 2 commits into
mainfrom
feat/lab-table-drag-columns

Conversation

@humbertovirtudes

@humbertovirtudes humbertovirtudes commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of #3639 and #3956 (drag-and-drop Table columns).

Stack: #14028 → #14018 → #14019 → #14020

The first commit is #14028. Review the last commit, feat(lab): reorder Table columns by keyboard and by taps.

User need

People reorder a table's columns to put the ones they compare side by side, for example after they show a column with column settings. A keyboard or screen-reader user needs to do that without a drag, and so does a pointer or finger user who cannot drag (WCAG 2.5.7). Today a Table has no column reorder.

Design

useTableDragAndDropColumns({reorderable, columnKeys}) in Lab returns a Table plugin. This pull request ships its reorder mode; #14019 adds the drag.

const [order, setOrder] = useState(() => columns.map(column => column.key));
const reorderable = useMemo(
  () => createReorderable({onReorder: ({key, to}) => setOrder(keys => moveKey(keys, key, to))}),
  [],
);
const dragColumns = useTableDragAndDropColumns({reorderable, columnKeys: order});
<Table data={rows} columns={byKeys(columns, order)} idKey="id" plugins={{dragColumns}} />
  • One reorder object. The plugin takes the createReorderable object (spec:AST-103 FR8): onReorder({key, to}) reports the column's key and its index after the move among columnKeys, and isReorderable(key) keeps a column in place. The object's start(key) turns on reorder mode for a column from the app's own action, such as a "Move column" menu item (FR4a), through feat(core): a Lab collection that runs its own reorder mode shares List's reorder parts #14028's mountReorderStarter.
  • The caller owns the order. columnKeys lists the columns people can reorder, in their order. With column settings, pass useTableColumnSettingsState's activeColumnKeys and apply the move to them: a hidden column keeps its place in the settings. A column outside columnKeys, such as the selection column, gets no handle and does not count.
  • A handle in each header cell. The handle is a toggle button named "Reorder" and the header's text, read block by block with Core's getNodeText (feat(core): a Lab collection that runs its own reorder mode shares List's reorder parts #14028) as Table's resize handle reads it. It sits in the header cell's overlay slot, so the column header keeps its own name. The reorderable's handle option places it (AST-103 FR1): at the cell's end by default, or at its start, clear of a resize boundary. With revealBehavior: 'adaptive', it shows while its header cell is hovered or holds the focus where the pointer is fine, through Core's useContainerReveal. Its grip and target reuse List's reorder handle sizes. A kept column gets no handle, and its header stays as it is, with no room kept for one: the plugin finds header cells by Table's data-column-key.
  • Reorder mode (AST-103 FR4). Space or Enter on the handle starts the mode. Left and Right move the column one place at a time, mirrored in right-to-left. Each move reports at once, the focus stays on the handle (and returns to it after a move from a hint button a screen reader focused), and the column scrolls into view. List's own mode hint (feat(core): a Lab collection that runs its own reorder mode shares List's reorder parts #14028's ReorderModeHint, inline axis) offers Move left, Move right and Done as buttons, so a tap reorders too. Escape, Done or the handle again ends the mode. An insertion line marks the edge the column came in through (design:ordered-collection-reordering DR7). A kept column at either end bounds the moves, through List's movableRange ("Can't move past Task").
  • Announcements. The plugin's host inside the Table owns the announcer, so a Table in a Dialog announces in the Dialog. Each move is announced once, after it renders, with List's strings (reorderMessagesFrom): "Owner, position 3 of 5, after Status, before Due" and "Done, Owner at position 4 of 5". Places count every column in columnKeys, so column windowing does not change them, and an unmounted neighbour is named by its header text.
  • One commit per table commit. The plugin keeps its latest options in a committed ref, and the reorder lands a move once, from the table's commit.

Owner decisions

Testing

Check Result
vitest --project ui packages/lab/src/TableDragAndDrop 11/11 pass; a kept column's header takes no handle styles. New, each failing before the fix: a move from a focused Move right button returns the focus to the handle; with the plugin's owner outside a modal Dialog that holds its Table, a move is announced in the Dialog's own live region. Also: a header with two text blocks names its handle "Reorder Due date"; one handle per ordered column, and the header keeps its name; a revealed handle stays named and in the tab order; keyboard moves, one report each, focus kept, announcements; right-to-left; a kept column refused by name; the hint's buttons; column settings' active columns; new: reorderable.start('owner') focuses Owner's handle in reorder mode, and Right then moves it
Chromium 149 (Chrome for Testing 149.0.7827.55), TableDragAndDropColumns.a11y.chromium.spec.ts 5/5 pass at this commit's earlier head, and all 16 pass at the top of the stack: reorder mode with the hint's three buttons, the line at the edge the column came in through, the focus kept on a move toward the start and the end, Escape; right-to-left; column settings with a pinned, kept column that stays pinned after an inline scroll of 200 px; a revealed handle at opacity 0 at rest and 1 on its header's hover and on focus; 60 windowed columns stay windowed (fewer than 20 mounted) while a column moves 9 places, stays in view and is announced "after Metric 11, before Metric 12"
Lab, Storybook and Core typecheck; pnpm build; Storybook build pass
At the top of the stack (#14020): vitest --project ui packages/core packages/lab 1,104 files, 26,825 tests pass
eslint --max-warnings=0 (strict), Prettier pass
pnpm check:repo (knowledge, changesets, i18n runtime and catalog, sync), changeset coverage, scripts/shared-identity.test.mjs (7/7) pass
check:component-import-boundaries --base-ref origin/main; pnpm size:pages --base origin/main hold; every reference page +0 / +0 bytes
pnpm review:pre --base #14028's branch 0 findings; 1,871 authored lines; merge clean
Swizzle proof, slice 1 with the lab__useTableDragAndDropColumns sample (without it the hook's render fails) pass

Scope

Components: Table, useTableDragAndDropColumns

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

@vercel

vercel Bot commented Nov 29, 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 Dec 2, 2026 9:38am UTC

Request Review

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

astracat-bot Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Dec 2, 2026, 9:35 AM UTC

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 42fbcb1

⏳ Building… Until it's ready, Storybook · Sandbox open the branch's previous preview.

Current run: Heavy CI deferred: runs when review passes and before merge. Lint, typecheck and any path-filtered checks ran on this push.


Generated by PR Enrichment workflow | View current CI run

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

Approval waits on an engineering owner's spec decision, and four fixes are needed.

No current spec makes Table an adopting collection of the reorderable spec (AST-103), or defines useTableDragAndDropColumns, its columnKeys input and its Lab-local inline-axis engine. The description lists these as owner decisions, and the Lab exemption does not apply because the pull request also changes Core's catalog and Storybook. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, or points to the spec that should govern it; the author may approve, as an engineering owner.

Blocking:

  • The hint's move buttons set no position, so their touch bands anchor to the hint surface, and a finger tap just outside a move glyph lands on Done instead of moving the column (useTableDragAndDropColumns.tsx:185, AST-094 FR42).
  • The hint, its buttons, boundsOf and messagesFrom copy Core's renderAnchoredHint, reorder HintButton, boundsOf and messagesFrom, and have already drifted (no fade-in, no positioned button), so export Core's versions through @astryxdesign/core/internal/reorder and reuse them.
  • reorder.commit() runs from two layout Effects on each table commit, and the second pass reads layout right after the first pass's style writes, which forces a second synchronous layout update per move; write the configuration before layout Effects run and commit once.
  • reorderable.start(key) never reaches this plugin, so an app's "Move column" action enters no reorder mode (AST-103 FR4a).
Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: columns reorder by keyboard and by taps. Verified.
  • Claim: Table has no column reorder today. Reported.
  • Claim: this ships reorder mode only, and the drag comes later. Verified.
  • Claim: a move reports the column's key and its index among the listed columns, and a kept column stays in place. Verified.
  • Claim: with column settings, the active columns own the order, and unlisted columns get no handle. Verified.
  • Claim: the handle is a named toggle in the header overlay, and the header keeps its own name. Verified.
  • Claim: the handle sits at the start or the end, with an adaptive reveal. Verified in the code; the reveal opacity is reported.
  • Claim: Space or Enter starts the mode, Left and Right move one place (mirrored in right-to-left), each move reports once, focus stays on the handle, and the column scrolls into view. Verified; Space and the scroll come from the author's browser run.
  • Claim: the hint's Move left, Move right and Done buttons let a tap reorder. Verified for a tap on a glyph; the coarse-pointer targets are broken (blocking).
  • Claim: Escape, Done or the handle again end the mode. Verified.
  • Claim: a line marks the edge the column came in through. Verified in the code; the browser run is reported.
  • Claim: a kept end column bounds the moves and is announced by name. Verified.
  • Claim: each move is announced once after it renders, and Done announces the final place. Verified.
  • Claim: places count every listed column, and unmounted neighbours are named. Verified.
  • Claim: Core adds the Move left and Move right messages with a chore changeset, and apps see no change. Verified.
  • Claim: Core's reorder engine moves only along the block axis. Verified.
  • Claim: the plugin shares Core's strings, announcer, layer, dismissal, reveal and touch hit area. Verified as imports; the hint surface is a copy (blocking).
  • Claim: the Testing table's results (unit, mutation, browser, typecheck and build, suites, lint, repository checks, size, pre-review). Reported; typecheck and lint pass in CI on this head, and the authored line count is verified.
  • Claim: the scope checklist. Verified.
  • File: .changeset/list-reorder-move-left-right.md. Clear.
  • File: apps/storybook/stories/TableDragAndDropColumns.stories.tsx. Clear.
  • File: packages/core/locales/en.json. Clear.
  • File: packages/lab/src/TableDragAndDrop/__tests__/TableDragAndDropColumns.a11y.chromium.spec.ts. Clear (not run).
  • File: packages/lab/src/TableDragAndDrop/columnReorder.ts. Copied boundsOf; double layout pass.
  • File: packages/lab/src/TableDragAndDrop/useTableDragAndDropColumns.doc.mjs. Clear.
  • File: packages/lab/src/TableDragAndDrop/useTableDragAndDropColumns.test.tsx. Clear (not run).
  • File: packages/lab/src/TableDragAndDrop/useTableDragAndDropColumns.tsx. Touch targets, copied hint, double layout pass, start(key), two notes.
  • File: packages/lab/src/index.ts. Clear.

Automated review (maintainer link)

backgroundColor: 'transparent',
color: colorVars['--color-icon-secondary'],
cursor: {
default: 'grab',

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: this pull request has no drag, so a grab cursor invites a drag that does nothing. Keep the default cursor until the drag lands.

});
reorder.commit();
});
// Ends reorder mode in progress as the plugin goes.

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): dispose() cancels the pending move and hides the line, but leaves the mode set. Suggested: "Cancels a pending move and hides the line when the plugin unmounts."

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

Approval waits on an engineering owner's spec decision, and six fixes are needed.

No current spec makes Table an adopting collection of the reorderable spec (AST-103), or defines useTableDragAndDropColumns, its columnKeys input and its Lab-local inline-axis engine; the description lists these as owner decisions, and the Lab exemption does not apply because the pull request also changes Core's catalog, Storybook and a CLI test sample. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, or points to the spec that should govern it; the author may do so as an engineering owner.

Blocking:

  • The hint's move buttons set no position, so their touch bands anchor to the hint and a finger tap just outside a move glyph lands on Done instead of moving the column (useTableDragAndDropColumns.tsx:185, AST-094 FR42).
  • Miss: useAnnounce() runs in the hook's caller (useTableDragAndDropColumns.tsx:477), so when the Table sits in a Dialog that the same component renders, every move and Done announcement goes to the page's live region behind the modal and is not heard; call it in ColumnReorderHost instead (AST-103 FR4, AST-086 FR14).
  • Miss: after a move from the hint nothing returns focus to the handle (columnReorder.ts:190-208, :316-334), so a screen reader that moved focus onto Move right is left there and the next arrow press moves nothing (AST-103 FR4).
  • The hint, its buttons, boundsOf and messagesFrom copy Core's renderAnchoredHint, reorder HintButton, boundsOf and messagesFrom and have already drifted (no fade-in, no positioned button, no focus return), so export Core's versions through @astryxdesign/core/internal/reorder and reuse them.
  • reorderable.start(key) never reaches this plugin, so an app's Move column action enters no reorder mode (AST-103 FR4a).
  • reorder.commit() runs from two layout Effects on each table commit, and the second pass reads layout right after the first pass's style writes, which forces a second synchronous layout per move; write the configuration before layout Effects run and commit once.
Claims and files checked

Review mode: full; reason: history

  • Claim: columns reorder by keyboard and by taps. Verified.
  • Claim: Table has no column reorder today. Reported.
  • Claim: this ships reorder mode only, and the drag comes later. Verified.
  • Claim: a move reports the column's key and its index among the listed columns, and a kept column stays in place. Verified.
  • Claim: with column settings, the active columns own the order, and unlisted columns get no handle. Verified.
  • Claim: the handle is a named toggle in the header overlay, and the header keeps its own name. Verified.
  • Claim: the handle sits at the start or the end, with an adaptive reveal and List's handle sizes. Verified in the code; the reveal opacity is reported.
  • Claim: Space or Enter starts the mode, Left and Right move one place (mirrored in right-to-left), each move reports once, and the column scrolls into view. Verified.
  • Claim: the focus stays on the handle on each move. False when a screen reader has moved focus into the hint (blocking).
  • Claim: the hint's Move left, Move right and Done buttons let a tap reorder. Verified; the coarse-pointer targets are broken (blocking).
  • Claim: Escape, Done or the handle again end the mode. Verified.
  • Claim: a line marks the edge the column came in through. Verified in the code.
  • Claim: a kept end column bounds the moves and is announced by name. Verified.
  • Claim: each move is announced once after it renders, and Done announces the final place. Verified outside a modal; false inside a modal the hook's caller renders (blocking).
  • Claim: places count every listed column under windowing, and unmounted neighbours are named. Verified.
  • Claim: Core adds the Move left and Move right messages with a chore changeset, and apps see no change. Verified.
  • Claim: Core's reorder engine moves only along the block axis. Verified.
  • Claim: the plugin shares Core's strings, announcer, layer, dismissal, reveal and touch hit area. Verified as imports; the hint surface is a copy (blocking).
  • Claim: the Testing table's results. Reported.
  • Claim: the scope checklist. Verified.
  • File: .changeset/list-reorder-move-left-right.md. Clear.
  • File: apps/storybook/stories/TableDragAndDropColumns.stories.tsx. Clear.
  • File: packages/cli/test/swizzle-proof/samples.mjs. Clear.
  • File: packages/core/locales/en.json. Clear; the key namespace waits on the owner decision.
  • File: packages/lab/src/TableDragAndDrop/__tests__/TableDragAndDropColumns.a11y.chromium.spec.ts. Clear (not run).
  • File: packages/lab/src/TableDragAndDrop/columnReorder.ts. Focus after a hint move, copied boundsOf, double layout pass.
  • File: packages/lab/src/TableDragAndDrop/useTableDragAndDropColumns.doc.mjs. Clear.
  • File: packages/lab/src/TableDragAndDrop/useTableDragAndDropColumns.test.tsx. Clear (not run).
  • File: packages/lab/src/TableDragAndDrop/useTableDragAndDropColumns.tsx. Touch targets, modal announcements, copied hint, start(key), double layout pass, three notes.
  • File: packages/lab/src/index.ts. Clear.

Automated review (maintainer link)

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

This pull request is reviewed as part of its stack; see the review on #14020.

Automated review (maintainer link)

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

This pull request is reviewed as part of its stack; see the review on #14020.

Automated review (maintainer link)

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

This pull request is reviewed as part of its stack; see the review on #14020.

Automated review (maintainer link)

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

This pull request is reviewed as part of its stack; see the review on #14020.

Automated review (maintainer link)

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

This pull request is reviewed as part of its stack; see the review on #14020.

Automated review (maintainer link)

…st's reorder parts

A new internal entry, @astryxdesign/core/internal/reorder-mode, gives Lab the parts of List's reorder: the mode hint, which now offers Up and Down or Left and Right, the strings, the pointer input with a finger's hold, the edge autoscroll, the drop bounds and the preview copy. internal/reorder gains mountReorderStarter, so a reorderable object's start(key) reaches such a collection. List's session uses the same parts, so List does not change. The catalog gains Move left and Move right.
useTableDragAndDropColumns puts a reorder handle in the header cell of each column in columnKeys. The handle turns on reorder mode: Left and Right move the column one place at a time, mirrored in right-to-left, and List's mode hint offers the moves and Done as buttons. Each move reports once, and announces the column's place with List's reorder strings after it lands. The reorderable's handle option places the handle and reveals it, and its start(key) turns on the mode from the app's own action.
@humbertovirtudes
humbertovirtudes force-pushed the feat/lab-table-drag-columns branch from bf634c2 to 42fbcb1 Compare December 2, 2026 09:24

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

This pull request is reviewed as part of its stack; see the review on #14020.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — 42fbcb1f Deployed Dec 2, 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. needs:design-review Affects visuals — Design should review needs:spec-owner-review Current knowledge records await owner approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant