Repository navigation
docs(useTableSortable): the plugin does not reorder rows; show how to sort data - #12493
Conversation
… how to sort data
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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'}])infersdirection: string; typing it asuseState<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
sortableto get a control. Verified in the description and againstresolveSortKey. - Claim (changeset, description):
allowUnsortedStatedefaults totrue. Verified against@default trueand?? trueinuseTableSortable.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, anduseTableSortableStatereturnssortedDataandsortConfig. 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.
| {key: 'age', header: 'Age', sortable: true}, | ||
| ]; | ||
|
|
||
| const [sort, setSort] = useState([{sortKey: 'name', direction: 'ascending'}]); |
There was a problem hiding this comment.
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.
Reader impact
People and agents who add sorting to a Table could not tell from
astryx component useTableSortablewhether 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 onlytransformHeaderCell(sort button, indicator, context-menu actions); it never touchesdata.allowUnsortedStatedefaults totrue(cfg.allowUnsortedState ?? true). A column needssortable: trueorsortable: {sortKey}(resolveSortKey).packages/core/src/Table/plugins/sortable/useTableSortableState.tsx: returnssortedDataandsortConfig.Correction
useTableSortabledescription, usage text, and thesort/onSortChangeprops now start with: the plugin adds the header sort controls but does not reorder rows; sort your data from the sort state, or useuseTableSortableState.sortableto get a control.allowUnsortedStatedefault corrected fromfalsetotrue(it matched neither the code nor the JSDoc).datafromsort, anduseTableSortableState+useTableSortable(sortConfig).Evidence
astryx component useTableSortableon this branch shows the new first sentences, the corrected default, and both examples.Scope
Components: useTableSortable
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.