Repository navigation
fix(Table): useTableSortableState sorts an Invalid Date like null instead of throwing - #12921
josephfarina wants to merge 2 commits into
Conversation
…tead of throwing [skip ci]
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Approval waits on one decision. No current spec says which values count as missing in useTableSortableState's default comparator, or where they sort. Counting an Invalid Date as missing (last in ascending order, first in descending order) therefore needs an engineering owner to confirm it, or to point to the spec that already decides it. An engineering owner records that decision by commenting /approve-spec with this head's full commit SHA, and as an engineering owner the author may do so.
- Not blocking, but worth knowing: the Table's default cell renderer (
defaultCellRendererinpackages/core/src/Table/columnUtils.ts) still callstoISOString()on any Date. A sorted Table whose Date column has norenderCellstill throwsRangeError: Invalid time valueon the same value. One shared Date-to-text helper for it andtoSortableStringwould close that, here or in a follow-up.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claims
- Changeset: the hook no longer throws when a sorted column holds an Invalid Date. Verified: the two new tests fail on the base with
RangeError: Invalid time valueand pass on this head. - Changeset: the default comparator treats an Invalid Date like
null,undefinedandNaN, last ascending and first descending. Verified:useTableSortableState.tsx:37-43and:186-196, the descending flip at:234, and both new tests. - Description: a Table sorting with the hook crashed on an Invalid Date because the comparator called
toISOString(). Verified on the base (toSortableString, line 39). - Description: valid dates keep sorting by their time. Verified: the earlier date sorts first in both new tests, and the collator path is unchanged.
- Description: only
null,undefinedandNaNcounted as missing before, and other values reachedtoSortableString. Verified in substance: two numbers take the numeric path first. - Description:
isMissingSortValueis the one place that decides which values are missing. Verified: it is defined at:37-43and used only at:186-187. - Description: missing values keep their existing order, and a custom comparator still takes over for its key. Verified:
:188-196and:228-231. - Description: no current spec decides where missing values sort, and no sortable module record exists. Verified: the Table component spec has no such clause.
- Description: the existing tests and the hook doc put
null,undefinedandNaNlast ascending. Verified: the NaN and null test suites, and the doc's comparators text. - Description: the open docs pull request #12884 edits the same doc line, and the Invalid Date sentence follows after it lands. Verified that #12884 is open and edits that line. The doc sentence is not in this pull request.
- Description: the ascending test throws on the base. Verified, and the descending test throws there too.
- Description: a patch changeset for
@astryxdesign/core. Verified.
- Changeset: the hook no longer throws when a sorted column holds an Invalid Date. Verified: the two new tests fail on the base with
- Files
.changeset/sortable-state-invalid-date.md: clear.packages/core/src/Table/plugins/sortable/useTableSortableState.test.tsx: clear. Both new cases fail on the base and pass here.packages/core/src/Table/plugins/sortable/useTableSortableState.tsx: the placement waits on the decision above. The rewritten comment at:181-185has one non-blocking style suggestion. The hook doc and the default cell renderer in other files are consistent except for the two notes above.
|
/approve-spec c1aaf66 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet.
The earlier hold is settled: an engineering owner approved, for this head, counting an Invalid Date as a missing value (last in ascending order, first in descending order). The two new tests fail on the base with RangeError: Invalid time value and pass on this head, and nothing blocks.
- Not blocking, for the planned follow-up: the Table's default cell renderer (
defaultCellRendererinpackages/core/src/Table/columnUtils.ts) still callstoISOString()on any Date, so a sorted Table whose Date column has norenderCellstill throws on the same value.
Claims and files checked
Review mode: incremental; reason: none
- Claims
- Changeset: the hook no longer throws when a sorted column holds an Invalid Date. Verified: both new tests fail on the base with
RangeError: Invalid time valueand pass on this head. - Changeset: the default comparator treats an Invalid Date like
null,undefinedandNaN, last in ascending order and first in descending order. Verified:useTableSortableState.tsx:37-43and:184-194, the descending flip at:232, and both new tests. - Changeset: a patch fix for
@astryxdesign/core. Verified. - Description: a Table that sorts with the hook crashed on an Invalid Date because the comparator called
toISOString(). Verified on the base (toSortableString) and by the failing tests there. - Description: valid dates keep sorting by their time. Verified: the earlier date sorts first in both new tests, and the collator path is unchanged.
- Description: only
null,undefinedandNaNcounted as missing before, and other values went totoSortableString. Verified in substance: two numbers take the numeric path first. - Description:
isMissingSortValueis the one place that decides which values are missing. Verified: defined at:37-43and used only at:184-185. - Description: missing values keep their existing order, and a custom comparator still takes over for its key. Verified:
:186-194and:226-229. - Description: no current spec decides where missing values sort, and no sortable module spec exists. Verified: the Table component spec has no such clause.
- Description: the existing tests and the hook doc put
null,undefinedandNaNlast in ascending order. Verified: the NaN and null test suites, and the hook doc's comparators text. - Description: the open docs pull request #12884 edits the same doc line, and the Invalid Date sentence follows after it lands. Verified that #12884 is open; the sentence is not in this pull request.
- Description: the new tests throw on the base. Verified: both fail there with
RangeError. - Description: the author's preflight passed its install, build, typecheck and UI test gates. A statement about the author's run, not the code; consistent with this review, where install, the Core and theme builds and the test file pass.
- Description: the locale re-sort test fails at the merge base on the author's machine. Not reproduced: it passes on both the base and this head here.
- Description follow-ups: the default cell renderer still throws on an Invalid Date, and the hook doc sentence comes later. Verified:
columnUtils.ts:291-292anduseTableSortableState.doc.mjs:58are unchanged.
- Changeset: the hook no longer throws when a sorted column holds an Invalid Date. Verified: both new tests fail on the base with
- Files
.changeset/sortable-state-invalid-date.md: clear.packages/core/src/Table/plugins/sortable/useTableSortableState.test.tsx: clear. Both new cases fail on the base and pass here.packages/core/src/Table/plugins/sortable/useTableSortableState.tsx: clear. The earlier comment suggestion is applied; consistent with the hook doc and the default cell renderer apart from the two follow-ups.
|
Owner decision (engineering owner, covering #12921 in this batch at its current head): a sorted Table column counts an invalid Date as a missing value. |
- #12921 fix(Table): useTableSortableState sorts an Invalid Date like null instead of throwing Author: @josephfarina - #12911 perf(cli): read a project's lockfile only for an Astryx package it has not installed Author: @josephfarina - #12388 fix(core): a theme radius of different corners reaches what a Card, a Dialog and a menu hand each corner to Author: @josephfarina
|
Landed in #12945. |
What changes for users
A Table that sorts with
useTableSortableStatecrashed when a sorted column held an Invalid Date (for examplenew Date('not a date')from a bad API value). The default comparator callstoISOString(), which throws aRangeErrorfor an Invalid Date. Now an Invalid Date sorts like a missing value: last in ascending order, first in descending order. Valid dates keep sorting by their time.Root cause
defaultComparetreated onlynull,undefinedandNaNas missing. Every other value went totoSortableString, and that calledtoISOString()on anyDate, valid or not.Fix
A new
isMissingSortValuehelper is the one place that decides which values are missing. It now also counts aDatewhosegetTime()isNaN. Missing values keep their existing order, so an Invalid Date goes wherenullandNaNalready go. No current record decides where missing values sort. The existing tests and the doc'scomparatorstext putnull,undefinedandNaNlast in ascending order, so an Invalid Date follows them. A custom comparator still takes over completely for its key.Spec and records
pnpm specs:for packages/core/src/Table/plugins/sortable/useTableSortableState.tsxroutes tocomponent:Table. No sortable module record exists, and no Table claim decides where missing values sort, so this fix creates no new policy. The doc line that lists the missing values (null, undefined and NaN) is also edited in the open docs PR #12884; it gains "an Invalid Date" in a follow-up after that lands, so the two PRs don't conflict.Tests
useTableSortableState.test.tsxadds "Invalid Date handling": an Invalid Date sorts last in ascending order and first in descending order, next to the existing NaN and null cases. On main the comparator throws a RangeError for these rows.Follow-ups (not in this PR)
columnUtils.ts) also callstoISOString()on any Date, so a column withoutrenderCellstill throws when it renders an Invalid Date. Fixing it means deciding what text an Invalid Date shows, so it is a separate change.comparatorstext gains "an Invalid Date" after docs: useTableSortableState comparator rules; Table has no row-click prop #12884 lands (same line).Changeset
[fix]for@astryxdesign/core(patch).preflight: pass c1aaf66 (test-node left to the batch: 2,433 files)