Skip to content

docs(useTableSortable): the plugin does not reorder rows; show how to sort data - #12493

Merged
josephfarina merged 1 commit into
mainfrom
ca2-sortable-docs
Nov 18, 2026
Merged

josephfarina merged 1 commit into
mainfrom
ca2-sortable-docs

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

Reader impact

People and agents who add sorting to a Table could not tell from astryx component useTableSortable whether the plugin sorts the rows or only manages the header state, so they read the package type files. After this change, the answer's first sentences say it, and two examples show how to get sorted rows.

Source of truth

  • packages/core/src/Table/plugins/sortable/useTableSortable.tsx: the plugin has only transformHeaderCell (sort button, indicator, context-menu actions); it never touches data. allowUnsortedState defaults to true (cfg.allowUnsortedState ?? true). A column needs sortable: true or sortable: {sortKey} (resolveSortKey).
  • packages/core/src/Table/plugins/sortable/useTableSortableState.tsx: returns sortedData and sortConfig.

Correction

  • useTableSortable description, usage text, and the sort / onSortChange props now start with: the plugin adds the header sort controls but does not reorder rows; sort your data from the sort state, or use useTableSortableState.
  • The description says a column needs sortable to get a control.
  • allowUnsortedState default corrected from false to true (it matched neither the code nor the JSDoc).
  • Two examples: sorting a copy of data from sort, and useTableSortableState + useTableSortable(sortConfig).
  • Chinese and dense text match.

Evidence

astryx component useTableSortable on this branch shows the new first sentences, the corrected default, and both examples.

Scope

Components: useTableSortable

  • This PR changes documentation only, or names every necessary generated artifact.
  • Runtime, API, visual, and policy changes were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project node packages/cli/test/{experimental-isolation,core-doc-quality,core-doc-types,core-prop-docs,golden-reads,docs-graph}.test.mjs: 82 passed (no golden change).
  • pnpm review:pre: 0 findings.

@josephfarina
josephfarina marked this pull request as ready for review November 18, 2026 00:01
@vercel

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

Request Review

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

astracat-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 12:25 AM UTC

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 2275e37

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
TableBody 3.5 kB (0) · 3.3 kB CSS (0) — — · ✓ · ✗
TableFooter 3.5 kB (0) · 3.3 kB CSS (0) — — · ✓ · ✗
TableHeader 3.5 kB (0) · 3.3 kB CSS (0) — — · ✓ · ✗
5 more components
Component Size LoC Visual · A11y · RTL
TableRow 7.1 kB (0) · 4.0 kB CSS (0) — — · ✓ · ✗
Table 121.8 kB (0) · 19.8 kB CSS (0) — — · ✓ · —
TableCell 104.7 kB (0) · 19.3 kB CSS (0) — — · ✓ · ✓
TableHeaderCell 104.5 kB (0) · 19.1 kB CSS (0) — — · ✓ · ✓
TableSelectionToolbar 76.6 kB (0) · 14.1 kB CSS (0) — — · ✓ · ✓

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

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@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: CI has not finished on this head yet.

The useTableSortable doc now matches the hook: the plugin only renders the header sort controls, the documented allowUnsortedState default is true as in the code, and the two examples show how to get sorted rows. There are no blocking findings.

  • Optional: example 1 fails strict TypeScript as written, because useState([{sortKey: 'name', direction: 'ascending'}]) infers direction: string; typing it as useState<TableSortState<'name' | 'age'>>(…) makes the rest compile unchanged (see the inline note).
Claims and files checked

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

  • Claim (changeset): the doc's first sentence says the plugin adds header sort controls but does not reorder rows. Verified in the description and usage text and in the CLI output.
  • Claim (changeset): the doc shows two ways to sort the data. Verified: two examples.
  • Claim (changeset): a column needs sortable to get a control. Verified in the description and against resolveSortKey.
  • Claim (changeset, description): allowUnsortedState defaults to true. Verified against @default true and ?? true in useTableSortable.tsx.
  • Claim (changeset): no API or behavior change. Verified: only a doc module and a changeset change, and the API surface comparison lists no rows.
  • Claim (description): the plugin only transforms header cells and never touches data, and useTableSortableState returns sortedData and sortConfig. Verified in the source.
  • Claim (description): the Chinese and dense text match, the CLI shows the new lead, default and examples, the named CLI doc tests pass (82) with no golden change, and pre-review reports no findings. Verified by reading, a CLI run, a test run and a pre-review run.
  • File .changeset/sortable-plugin-does-not-sort.md: clear.
  • File packages/core/src/Table/useTableSortable.doc.mjs: one non-blocking typing note on example 1.

Automated review (maintainer link)

{key: 'age', header: 'Age', sortable: true},
];

const [sort, setSort] = useState([{sortKey: 'name', direction: 'ascending'}]);

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.

Optional: in TypeScript this useState infers direction: string, so useTableSortable({sort, onSortChange: setSort}) fails with TS2322 ("Type 'string' is not assignable to type 'TableSortDirection'"), and a[entry.sortKey] fails with TS7053 on a typed row. Typing the state makes the example compile with the rest unchanged:

const [sort, setSort] = useState<TableSortState<'name' | 'age'>>([
  {sortKey: 'name', direction: 'ascending'},
]);

TableSortState is exported from @astryxdesign/core/Table.

@josephfarina
josephfarina merged commit 771f5c5 into main Nov 18, 2026
145 of 146 checks passed
@github-actions
github-actions Bot deleted the ca2-sortable-docs branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 2275e371 Deployed Nov 18, 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.

1 participant