Repository navigation
fix(core): PowerSearch reads a date-only value as one day in one zone, and edits it there - #9655
Conversation
|
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 |
|---|---|---|---|
| PowerSearch · Storybook | 195.1 kB (+734 B) · 21.6 kB CSS (0) | 6,948 (+159) | ✓ · ✓ · ✓ |
Package size: @astryxdesign/core 6.24 MB packed (+3.5 kB); no new dependencies.
API changes: core +1 · ~0 · −0
1 API change (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Components · component PowerSearchToken |
prop timezoneID?: string |
<PowerSearchToken timezoneID={…} /> |
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approval waits on an engineering-owner decision on the proposed component:PowerSearch DEC-4, FR22 and FR23, which replace the current FR17 rule that the date editors read and write UTC days and settle the open isDateOnly: false question. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. These fixes are needed either way:
- With
timezoneIDunset, LabMobilePowerSearchnow shows one day on its token and row and another in its editor (Tokyo: token "Mar 8, 2024", calendar March 9), becausepowerSearchDateZone.tscopies Lab's four conversion helpers frommobilePowerSearchUtils.tswith a UTC fallback where Lab keeps the viewer's zone, so please keep one implementation in Core, have Lab call it, and correct the new Lab JSDoc. - The
[fix]changeset tag contradictsspec:AST-017FR5, FR6 and FR32, because the change replaces the documented UTC-day rule and its own text names a caller it breaks: please classify it per FR32 and FR33, and list in the record and the changeset thatformatFilterValueand the accessible label drop the time of day for every date-only value. <PowerSearch timezoneID="">now throwsRangeError: Invalid time zone specifiedon render where the base treated""as unset, so please testif (timezoneID)inresolveDateZone.- The required
lintcheck fails becauseformatFilterValue.test.tsis not Prettier-formatted, so please run Prettier on it.
The range editor's write path also has no test: the case named "reads and writes them in timezoneID" asserts only the read.
[Automated review]
| * UTC day, so this prop does not change a date value today. | ||
| * The zone date values are shown and edited in: tokens, rows and the date | ||
| * editors read a `date_absolute` in it and a picked day stores as its | ||
| * midnight there. Unset, the viewer's zone. |
There was a problem hiding this comment.
This no longer holds after the Core change. With timezoneID unset, the token and rows format through Core's formatFilterValue, which now reads UTC, while MobilePowerSearchValueEditor still reads the viewer's zone. In Tokyo a value saved for March 9 shows "Mar 8, 2024" on the token and March 9 in the calendar. Keep one zone rule for both, then describe it here.
|
|
||
| const pad = (n: number, width = 2) => String(n).padStart(width, '0'); | ||
|
|
||
| export function unixSecondsToISODate( |
There was a problem hiding this comment.
These four helpers repeat unixSecondsToISODate, unixSecondsToISODateTime, isoDateTimeToUnixSeconds and isoDateToUnixSeconds in packages/lab/src/MobilePowerSearch/mobilePowerSearchUtils.ts:521-592, which fall back to the viewer's zone instead of UTC. Keep one implementation in Core and have Lab call it, so the two cannot drift.
| timezoneID: string | undefined, | ||
| isDateOnly: boolean, | ||
| ): string | undefined { | ||
| if (timezoneID != null) { |
There was a problem hiding this comment.
An empty string passes this test, reaches Intl.DateTimeFormat, and makes <PowerSearch timezoneID=""> throw RangeError: Invalid time zone specified on render. The base treated "" as unset. Suggest if (timezoneID) {.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] PowerSearch: a `date_absolute` value reads as one day in one zone — on the token, in the accessible label and announcements, and in the edit popover's date editor — and the editor writes the day picked. Before, the token showed the device's day and the editor read and wrote the UTC day, ignoring `timezoneID`, so west of UTC a filter opened on the day after the one its token showed and re-picking that day moved the value a day earlier. Now, with `timezoneID` set, every reading uses that zone and a picked day stores as that zone's midnight (it stored UTC midnight before: a caller passing `timezoneID` sees a different saved instant, the midnight of the day shown, and a caller east of UTC that derived the day from the instant's UTC date reads the day before — read it in `timezoneID`); with `timezoneID` unset the stored day stays UTC midnight and the token now shows the UTC day too, so no stored value changes. `isDateOnly: false` now gets a date-and-time editor and a time on the token, reading and writing wall-clock time in `timezoneID`, else the viewer's zone; it was a date-only editor storing midnight. Range parts follow the date-only rule. |
There was a problem hiding this comment.
spec:AST-017 FR5 says a change that replaces the documented contract is not a fix. CURRENT FR17 documents UTC-day reads and writes, and this text names a caller the change breaks (east of UTC, reading the UTC date). FR6 and FR32 then make it [breaking], with the corrected contract and migration. Please also note that formatFilterValue and the accessible label drop the time of day for date-only values.
| so a field that passed `timezoneID` showed one day on its token and another | ||
| in its editor; the correction makes the editor honor the documented prop. | ||
| With no `timezoneID` the stored day of a date-only value is unchanged (UTC | ||
| midnight in, UTC midnight out) and only the token's text changes where the |
There was a problem hiding this comment.
With no timezoneID, the accessible label and the public formatFilterValue also change, in every zone: they drop the time of day and read UTC (Los Angeles: "Mar 8, 2024, 4:00 PM" becomes "Mar 9, 2024"). "No caller in the repository does" is the likelihood argument spec:AST-017 FR6 rules out.
| // Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
|
||
| import {describe, expect, it} from 'vitest'; | ||
| import { |
There was a problem hiding this comment.
Prettier wants this import on one line (import {formatDateAbsolute, formatFilterValue} from './formatFilterValue';). The required lint check fails here and never reaches ESLint.
| }); | ||
|
|
||
| describe('range parts are calendar days in the same zone', () => { | ||
| it('reads and writes them in timezoneID', () => { |
There was a problem hiding this comment.
Non-blocking: this case asserts only the read and that onChange was not called, so the DateRangeEditor write path (isoDateToUnixSeconds(range.start, zone)) has no test. Pick a range and assert each part stores that zone's midnight, or rename the case.
|
/approve-spec 84ab832 |
b461e88 to
84ab832
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision about the five functions this pull request adds to the published @astryxdesign/core/PowerSearch/utils entry point (resolveDateZone, unixSecondsToISODate, isoDateToUnixSeconds, unixSecondsToISODateTime, isoDateTimeToUnixSeconds). No spec decides them yet, so an owner either names them in the PowerSearch record or asks for a non-public home that Lab can import. The date-zone direction itself (DEC-4, FR22, FR23) is approved at this head. These fixes are needed either way:
- With
timezoneIDset, the exportedPowerSearchFilterEditorandPowerSearchTokenstill read UTC days, because PowerSearch passes notimezoneIDtocomponentsoverrides and neither part forwards one: a Tokyo field shows "Mar 11, 2024" beside an editor on March 10, so please pass and forward the zone (or narrow FR22 to the built-in parts). - The
[fix]patch changeset conflicts withspec:AST-017FR5, FR7 and FR32: it names a caller that must change (one reading the stored instant's UTC date), and the new helpers are an addition, so please classify the stored-instant change[breaking]with its migration under FR31 to FR34 and give any public helpers their own[feat]entry. - The changeset says each range part's day shows on the token and in the label, but the range token and
formatFilterValuestill read "date range", so please limit that sentence to the range editor. - The changeset credits
@xinzi, while your earlier changesets credit@imdreamrunner, so please credit the handle the release notes should thank.
Non-blocking: the FR22/FR23 verification row promises accessible-label checks that the new suite does not make.
[Automated review]
| saveButtonLabel={popoverSaveButtonLabel} | ||
| maxMenuItems={maxOperatorMenuItems} | ||
| isReadOnly={isReadOnly} | ||
| timezoneID={timezoneID} |
There was a problem hiding this comment.
The built-in popover gets the zone here, but the components Editor override a few lines up (<EditorOverride …/>) and the Token override (<TokenOverride …/>) get none, although PowerSearchEditorProps declares timezoneID. The exported PowerSearchFilterEditor also drops it before PowerSearchEditPopover. With timezoneID="Asia/Tokyo", the Editor override opens on March 10 beside a "Mar 11, 2024" token. Passing timezoneID={timezoneID} to EditorOverride and forwarding it in PowerSearchFilterEditor fixes the editor side.
| @@ -0,0 +1,7 @@ | |||
| --- | |||
| '@astryxdesign/core': patch | |||
There was a problem hiding this comment.
spec:AST-017 FR5 and FR32: this text names a caller that must change (one deriving the day from the stored instant's UTC date), so the stored-instant change is [breaking], not a patch [fix]. With a patch declared on main, FR34 asks for an opt-in beside the old behavior, or the change waits for a declared minor. The new public helpers are a [feat] addition (FR7).
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] PowerSearch: a `date_absolute` value reads as one day in one zone — on the token, in the accessible label and announcements, and in the edit popover's date editor — and the editor writes the day picked. Before, the token showed the device's day, the label showed a date and a time in `timezoneID`, and the editor read and wrote the UTC day without receiving `timezoneID`, so west of UTC a filter opened on the day after the one its token showed and re-picking that day moved the value a day earlier. Now a date-only value (`isDateOnly` unset or true) and each range part is a calendar day in `timezoneID`, else the UTC day: the token shows that day; the accessible label and `formatFilterValue` show that day with no time of day (UTC midnight March 9 in Los Angeles read "Mar 8, 2024, 4:00 PM" and reads "Mar 9, 2024"); the editor opens on it; and a picked day stores as that zone's midnight — with `timezoneID` set this is a different instant from the UTC midnight stored before, so a caller that derived the day from the instant's UTC date reads it in `timezoneID` instead; with `timezoneID` unset no stored value changes. `isDateOnly: false` is an instant: a date-and-time editor and a time on the token and label, in `timezoneID`, else the viewer's zone; it had the date-only editor and stored midnight. `@astryxdesign/core/PowerSearch/utils` adds the zone helpers (`resolveDateZone`, `unixSecondsToISODate`, `isoDateToUnixSeconds`, `unixSecondsToISODateTime`, `isoDateTimeToUnixSeconds`) so Lab reads dates the same way. |
There was a problem hiding this comment.
"each range part … the token shows that day; the accessible label and formatFilterValue show that day": the range token renders "date range" and formatFilterValue returns "date range" for a date_range. Only the range editor reads days. Suggested: "each absolute range part is read and written as a calendar day in timezoneID, else the UTC day, in the range editor".
|
|
||
| [fix] PowerSearch: a `date_absolute` value reads as one day in one zone — on the token, in the accessible label and announcements, and in the edit popover's date editor — and the editor writes the day picked. Before, the token showed the device's day, the label showed a date and a time in `timezoneID`, and the editor read and wrote the UTC day without receiving `timezoneID`, so west of UTC a filter opened on the day after the one its token showed and re-picking that day moved the value a day earlier. Now a date-only value (`isDateOnly` unset or true) and each range part is a calendar day in `timezoneID`, else the UTC day: the token shows that day; the accessible label and `formatFilterValue` show that day with no time of day (UTC midnight March 9 in Los Angeles read "Mar 8, 2024, 4:00 PM" and reads "Mar 9, 2024"); the editor opens on it; and a picked day stores as that zone's midnight — with `timezoneID` set this is a different instant from the UTC midnight stored before, so a caller that derived the day from the instant's UTC date reads it in `timezoneID` instead; with `timezoneID` unset no stored value changes. `isDateOnly: false` is an instant: a date-and-time editor and a time on the token and label, in `timezoneID`, else the viewer's zone; it had the date-only editor and stored midnight. `@astryxdesign/core/PowerSearch/utils` adds the zone helpers (`resolveDateZone`, `unixSecondsToISODate`, `isoDateToUnixSeconds`, `unixSecondsToISODateTime`, `isoDateTimeToUnixSeconds`) so Lab reads dates the same way. | ||
|
|
||
| @xinzi |
There was a problem hiding this comment.
The release notes render this as "thanks @xinzi". Your earlier changesets credit @imdreamrunner, the handle on this pull request.
| export { | ||
| isoDateTimeToUnixSeconds, | ||
| isoDateToUnixSeconds, | ||
| resolveDateZone, | ||
| unixSecondsToISODate, | ||
| unixSecondsToISODateTime, | ||
| } from './powerSearchDateZone'; |
There was a problem hiding this comment.
These five functions become public API on the published @astryxdesign/core/PowerSearch/utils entry point, and no record names them yet. An engineering owner needs to decide whether they stay public.
| * The one reading of a `date_absolute` value: a date-only value is its | ||
| * calendar day in the zone `resolveDateZone` names, a date-and-time value is | ||
| * its wall-clock time there. The token text, the accessible label, and the | ||
| * editors share it, so a value never reads as two days in one field. |
There was a problem hiding this comment.
Non-blocking: the editors do not call formatDateAbsolute. Suggested: "The token text and the accessible label share it. The editors read the same zone through resolveDateZone."
84ab832 to
f175024
Compare
|
/approve-spec f175024 |
f175024 to
64ff3b2
Compare
|
/approve-spec 64ff3b2 |
There was a problem hiding this comment.
Requesting changes. The date-zone direction (DEC-4, FR22, FR23) is approved at this head, and the code matches it: the token, the accessible label and the editor now read one day in one zone, and isDateOnly: false gets a date-and-time editor. One change is needed before merge:
- The
[fix]patch Changeset conflicts withspec:AST-017FR5, FR32 and FR34, because its own text says a caller that reads the stored instant's UTC date must change oncetimezoneIDis set, so please classify that storage change[breaking]with its migration for a declared minor, or ship it in this patch as an opt-in beside UTC-midnight storage.
Non-blocking: the western round-trip test also passes on the base, and no test checks that an Editor override or PowerSearchFilterEditor receives timezoneID.
[Automated review]
| @@ -0,0 +1,7 @@ | |||
| --- | |||
| '@astryxdesign/core': patch | |||
There was a problem hiding this comment.
spec:AST-017 FR5 and FR32: line 5 names a caller that must change when timezoneID is set (one that reads the stored instant's UTC date), so this storage change is [breaking], not a patch [fix]. With a patch declared on main, FR34 asks for an opt-in beside UTC-midnight storage, or the change waits for a declared minor with its migration (FR8, FR33).
| }); | ||
| }); | ||
|
|
||
| it('a date-only round trip through the editor keeps its day in a western zone', () => { |
There was a problem hiding this comment.
Non-blocking: this case also passes on the base, so it does not guard the stored instant. Picking a different day and then the token's day again, or using a timezoneID east of UTC, would make it fail on the old code.
64ff3b2 to
1dcfd92
Compare
|
/approve-spec 1dcfd92 |
There was a problem hiding this comment.
Requesting changes. The date-zone direction (DEC-4, FR23) is approved at this head, and the Core code matches it: the token, the accessible label and the editor now read one day in one zone.
Blocking:
- The
[fix]patch Changeset contradictsspec:AST-017FR5, FR32 and FR34: withtimezoneIDset, a newly picked day stores a different instant, and a filter saved as UTC midnight under a westerntimezoneIDnow reads a day earlier, so ship the storage change as[breaking]with a migration in a declared minor, or as an opt-in beside UTC-midnight storage in this patch. - The Changeset and the record's compatibility bullet leave out that
isDateOnly: falsevalues also lose their time of day and change zone informatFilterValue, the label and the token, and that released UTC-midnight values under a westerntimezoneIDshift a day; name both. - Lab
MobilePowerSearchnow shows "Mar 10, 2024" on anisDateOnly: falsetoken whose date-and-time editor opens on March 9, 7:00 PM (Los Angeles clock, notimezoneID), because the shared formatter prints the UTC day while that editor reads the viewer's zone; format that token and its row in the editor's zone and add a test.
One non-blocking comment-wording suggestion is inline.
[Automated review]
| @@ -0,0 +1,7 @@ | |||
| --- | |||
| '@astryxdesign/core': patch | |||
There was a problem hiding this comment.
spec:AST-017 FR5, FR32 and FR34: this change has released victims, so it cannot ship as a patch [fix]. With timezoneID set, a newly picked day stores that zone's midnight instead of UTC midnight, and a filter the released editor saved as UTC midnight March 9 under timezoneID="America/Los_Angeles" now reads March 8 on the token and in the editor on every device. FR6 rules out approval as a reason. Ship it as [breaking] with its migration in a declared minor (FR31, FR33), or in this patch as an opt-in beside UTC-midnight storage (FR34, FR28).
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] PowerSearch: a `date_absolute` value reads as one day in one zone — on the token, in the accessible label and announcements, and in the edit popover's date editor — and the editor writes the day picked. Before, the token showed the device's day, the label showed a date and a time in `timezoneID`, and the editor read and wrote the UTC day without receiving `timezoneID`, so west of UTC a filter opened on the day after the one its token showed and re-picking that day moved the value a day earlier. Now a date-only value (`isDateOnly` unset or true) is a calendar day in `timezoneID`, else the UTC day: the token shows that day; the accessible label and `formatFilterValue` show that day with no time of day (UTC midnight March 9 in Los Angeles read "Mar 8, 2024, 4:00 PM" and reads "Mar 9, 2024"); the editor opens on it; and a picked day stores as that zone's midnight — with `timezoneID` set this is a different instant from the UTC midnight stored before, so a caller that derived the day from the instant's UTC date reads it in `timezoneID` instead; with `timezoneID` unset no stored value changes. Each absolute `date_range` part is read and written as a calendar day the same way in the range editor. A `components` Editor override and `PowerSearchFilterEditor` receive `timezoneID`. |
There was a problem hiding this comment.
Two observable changes are missing here (AST-017 FR7: the Changeset body is the whole declaration). formatDateAbsolute ignores isDateOnly, so for isDateOnly: false values formatFilterValue and the label also drop the time and read UTC when timezoneID is unset ("Mar 9, 2024, 7:00 PM" becomes "Mar 10, 2024" on a Los Angeles device). And values the released editor stored as UTC midnight under a western timezoneID now read a day earlier. Please name both here and in the record's compatibility bullet.
| // Core owns the zone rule: a calendar day reads in `timezoneID`, else the UTC | ||
| // day; an instant reads in `timezoneID`, else the viewer's zone. Lab calls the | ||
| // same conversions, so the token, the rows and the editors cannot drift. |
There was a problem hiding this comment.
This does not hold for isDateOnly: false. The token and rows format through Core's formatFilterValue, which now prints the UTC day with no time, while unixSecondsToISODateTime below reads the viewer's zone. On a Los Angeles clock with no timezoneID the token reads "Mar 10, 2024" and the editor opens on March 9, 7:00 PM (on the base both read March 9, 7:00 PM). Format the isDateOnly: false token and row text with the time in resolveDateZone(timezoneID, false), and add a Lab test for that token.
| * value written before a zone was given keeps its day. A wall-clock time | ||
| * (the Lab prototype's date-and-time editor) is an instant shown in | ||
| * `timezoneID`, else the viewer's zone, which `undefined` names: `Intl` and | ||
| * `Date` both default to it, so no zone name is needed for it. |
There was a problem hiding this comment.
Non-blocking (INV29): this sentence packs several topics into 38 words. Suggested: "A wall-clock time shows in timezoneID, else in the viewer's zone. undefined names the viewer's zone, because Intl and Date default to it."
1dcfd92 to
b195ea4
Compare
|
/approve-spec b195ea4 |
There was a problem hiding this comment.
Requesting changes. The date-zone direction (DEC-4, FR23) is approved at this head, and the code matches it: a date-only value now reads as one day on the token, in the accessible label and in the editor, and isDateOnly: false values keep their released reading.
Blocking:
- The
[fix]patch Changeset (.changeset/powersearch-date-zone.md:2,:5) needs to become[breaking]with its migration oncemaindeclares a minor, or thetimezoneIDstorage change needs to ship as an opt-in beside the released UTC-midnight behaviour, becausespec:AST-017FR5, FR32 and FR34 classify a correction that breaks persisted values (UTC midnight March 9 underAmerica/Los_Angelesnow reads March 8) as breaking, and FR6 rules out approval as a reason. - The Changeset's lead sentence and the title say every
date_absolutevalue now reads as one day, butisDateOnly: falsevalues still read as two days (your own tests atPowerSearchDateZone.test.tsx:389-427), so lead with "a date-onlydate_absolutevalue (isDateOnlyunset ortrue)" and say "date-only value" in the title.
One non-blocking comment-wording suggestion is inline.
[Automated review]
| @@ -0,0 +1,7 @@ | |||
| --- | |||
| '@astryxdesign/core': patch | |||
There was a problem hiding this comment.
spec:AST-017 FR5, FR32 and FR34: callers that pass timezoneID are released victims, so this cannot ship as a patch [fix]. A day picked under Asia/Tokyo now stores 2024-03-10T15:00Z instead of 2024-03-11T00:00Z, and a value the released editor saved as UTC midnight March 9 under America/Los_Angeles now reads March 8 on every device; line 5 itself tells those callers to re-save. FR6 rules out approval as a reason. Ship it as [breaking] with the migration once main declares a minor, or ship the zone-midnight reading as an opt-in beside the released behaviour (FR34, FR28).
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] PowerSearch: a `date_absolute` value reads as one day in one zone — on the token, in the accessible label and announcements, and in the edit popover's date editor — and the editor writes the day picked. Before, the token showed the device's day, the label showed a date and a time in `timezoneID`, and the editor read and wrote the UTC day without receiving `timezoneID`, so west of UTC a filter opened on the day after the one its token showed and re-picking that day moved the value a day earlier. Now a date-only value (`isDateOnly` unset or true) is a calendar day in `timezoneID`, else the UTC day: the token shows that day; the accessible label and `formatFilterValue` show that day with no time of day (UTC midnight March 9 in Los Angeles read "Mar 8, 2024, 4:00 PM" and reads "Mar 9, 2024"); the editor opens on it; and a picked day stores as that zone's midnight — with `timezoneID` set this is a different instant from the UTC midnight stored before, so a caller that derived the day from the instant's UTC date reads it in `timezoneID` instead, and a value the old editor stored as UTC midnight under a `timezoneID` west of UTC now reads the day before (UTC midnight March 9 under `America/Los_Angeles` reads March 8), the day it would have stored — re-save such values, or read them as UTC days; with `timezoneID` unset no stored value changes. Each absolute `date_range` part is read and written as a calendar day the same way in the range editor. An operator with `isDateOnly: false` is untouched: its token, label and editor read as before. A `components` Editor override and `PowerSearchFilterEditor` receive `timezoneID`. |
There was a problem hiding this comment.
The lead says "a date_absolute value reads as one day in one zone", but isDateOnly: false values still read as two days (token on the device's day, label in timezoneID, editor on the UTC day; PowerSearchDateZone.test.tsx:389-427). Suggested lead: "a date-only date_absolute value (isDateOnly unset or true), and each absolute date_range part, reads as one day in one zone". The title needs the same qualifier.
| // A calendar day reads in the one zone the editor uses; a value with a | ||
| // time of day keeps the token's released reading. |
There was a problem hiding this comment.
Non-blocking (INV29): two topics in one sentence, and "released reading" does not say what the reader sees. Suggested: "A date-only value reads in the editor's zone. A value with a time of day keeps the device's day."
There was a problem hiding this comment.
Changes requested: the date-zone fix is well tested and its record change is approved by an engineering owner, but its release category does not follow the repository's compatibility rules.
- The
[fix]patch Changeset contradictsspec:AST-017FR5, FR32 and FR34, because a caller that passestimezoneIDnow stores a different instant for a picked day (March 11 underAsia/Tokyostores2024-03-10T15:00Zinstead of2024-03-11T00:00Z) and sees values saved earlier under a western zone a day earlier; ship the zone-midnight storage as an opt-in beside the released behavior in this patch, or as[breaking]with its migration oncemaindeclares a minor.
When the Changeset is rewritten, say that a saved value also moves on a device at UTC, as the record does ("at or east of UTC"). Three new source comments could be shorter; the suggestions are inline and do not block.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] PowerSearch: a date-only `date_absolute` value (`isDateOnly` unset or `true`) reads as one day in one zone — on the token, in the accessible label and announcements, and in the edit popover's date editor — and the editor writes the day picked. Before, the token showed the device's day, the label showed a date and a time in `timezoneID`, and the editor read and wrote the UTC day without receiving `timezoneID`, so west of UTC a filter opened on the day after the one its token showed and re-picking that day moved the value a day earlier. Now a date-only value (`isDateOnly` unset or true) is a calendar day in `timezoneID`, else the UTC day: the token shows that day; the accessible label and `formatFilterValue` show that day with no time of day (UTC midnight March 9 in Los Angeles read "Mar 8, 2024, 4:00 PM" and reads "Mar 9, 2024"); the editor opens on it; and a picked day stores as that zone's midnight — with `timezoneID` set this is a different instant from the UTC midnight stored before, so a caller that derived the day from the instant's UTC date reads it in `timezoneID` instead, and a value the old editor stored as UTC midnight under a `timezoneID` west of UTC now reads the day before in the editor, and on the token east of UTC (UTC midnight March 9 under `America/Los_Angeles` reads March 8 everywhere; a Los Angeles device's token and the label already did), the day it would have stored — re-save such values, or read them as UTC days; with `timezoneID` unset no stored value changes. Each absolute `date_range` part is read and written as a calendar day the same way in the range editor. An operator with `isDateOnly: false` is untouched: its token, label and editor read as before. A `components` Editor override and `PowerSearchFilterEditor` receive `timezoneID`. |
There was a problem hiding this comment.
spec:AST-017 FR5, FR32 and FR34: callers that pass timezoneID are released victims, so this cannot ship as a patch [fix]. A March 11 pick under Asia/Tokyo stored 2024-03-11T00:00Z and now stores 2024-03-10T15:00Z, and this text tells callers to re-save values saved earlier. Either ship the zone-midnight storage as an opt-in beside the released UTC-midnight behavior (FR34, FR28), or mark it [breaking] with its migration once main declares a minor (FR31, FR33). When rewriting, "on the token east of UTC" should read "at or east of UTC": a UTC device's token moves too.
| // A calendar day reads in the one zone the editor uses; a value with a | ||
| // time of day keeps the token's released reading. |
There was a problem hiding this comment.
Non-blocking (INV29): two topics in one sentence, and "released reading" does not say what the reader sees. Suggested: "A date-only value reads in the editor's zone. A value with a time of day keeps the device's day."
| // A calendar day edits in the one zone the token and the label read it in. | ||
| // A value whose operator sets `isDateOnly: false` keeps the released | ||
| // date-only picker on the UTC day. |
There was a problem hiding this comment.
Non-blocking (INV29): "released" narrates history. Suggested: "A date-only value edits in the zone the token and the label use. An isDateOnly: false value edits its UTC day."
| timezoneID: string | undefined, | ||
| isDateOnly: boolean, | ||
| ): string | undefined { | ||
| // An empty string is no zone, as the formatter always read it. |
There was a problem hiding this comment.
Non-blocking (INV29): "as the formatter always read it" narrates history. Suggested: "An empty string means no zone."
e9f06ea to
4c96401
Compare
|
/approve-spec 4c96401 |
There was a problem hiding this comment.
Changes requested: the date-zone fix is well tested and its record change is approved by an engineering owner, but two items need fixing before merge.
- The
[fix]patch Changeset contradictsspec:AST-017FR5, FR32 and FR34, because a caller that passestimezoneIDnow gets a different stored instant for a picked day (March 11 underAsia/Tokyostored2024-03-11T00:00Z, which a Tokyo viewer's token and editor already read as one day, and now stores2024-03-10T15:00Z) and values saved earlier under a western zone read a day earlier, so ship the zone-midnight storage as an opt-in beside the released behavior in this patch, or as[breaking]with its migration in a declared minor. - In the sheet presentation a
componentsEditor override still receives notimezoneID(theEditorOverriderender inPowerSearchBottomSheet.tsx), although FR14 gives it the popover's props, FR25 says it receives the zone and the Changeset promises it, so passtimezoneIDthere and add a sheet case toPowerSearchDateZone.test.tsx.
The review also lists non-blocking suggestions: DEC-3's prototype differences that this change makes stale, an [experimental] Changeset for the sheet part, and comment wording.
[Automated review]
| @@ -0,0 +1,7 @@ | |||
| --- | |||
| '@astryxdesign/core': patch | |||
There was a problem hiding this comment.
spec:AST-017 FR5, FR32 and FR34: callers that pass timezoneID are released victims, so this cannot ship as a patch [fix]. A March 11 pick under Asia/Tokyo stored 2024-03-11T00:00Z (and a Tokyo viewer's token and editor already agreed) and now stores 2024-03-10T15:00Z; a value saved as UTC midnight under America/Los_Angeles reads a day earlier on a UTC device. Ship the zone-midnight storage as an opt-in beside the released behavior (FR34, FR28), or as [breaking] with its migration once main declares a minor (FR31, FR33, FR8).
| fieldLabel={draftField.label} | ||
| isDisabled={isEditorDisabled} | ||
| maxMenuItems={maxOperatorMenuItems} | ||
| timezoneID={timezoneID} |
There was a problem hiding this comment.
The built-in editor gets the zone here, but the EditorOverride this step renders (line 2409) still gets no timezoneID, while the popover passes it (PowerSearch.tsx:1266). FR14 gives the sheet's override "the props the popover presentation hands it, with the same meaning", and FR25 says it receives the zone. With timezoneID="America/Los_Angeles" the row reads "Due on Mar 9, 2024" but the override cannot know that day. Pass timezoneID={timezoneID} to it and add a sheet case to PowerSearchDateZone.test.tsx.
4c96401 to
314e6c9
Compare
|
/approve-spec 314e6c9 |
There was a problem hiding this comment.
Changes requested: the date-zone fix is well tested and its record change is approved by an engineering owner, but one item blocks merge.
- The
[fix]patch Changeset contradictsspec:AST-017FR5, FR32 and FR34, because a caller that passestimezoneIDnow stores a different instant for a picked day (March 11 underAsia/Tokyostored2024-03-11T00:00Z, which a Tokyo viewer's token and editor already read as one day, and now stores2024-03-10T15:00Z) and values saved earlier under a western zone read a day earlier, so ship the zone reading and storage fortimezoneIDcallers as an opt-in beside the released behavior in this patch, or as[breaking]with its migration oncemaindeclares a minor.
The sheet presentation's Editor override now receives timezoneID, which resolves the earlier finding. The review also lists non-blocking suggestions: two DEC-3 prototype differences this change makes stale, PowerSearchToken having no way to read the zone, and an [experimental] Changeset for the sheet part.
[Automated review]
314e6c9 to
7150d79
Compare
|
/approve-spec 7150d79 |
7150d79 to
5ec3631
Compare
|
/approve-spec 5ec3631 |
There was a problem hiding this comment.
Requesting changes: the date-zone fix matches the current PowerSearch record and its tests are thorough, but one regression guard needs to come back.
formatFilterValue.test.ts:277drops the Thai-calendar case forformatDateAbsoluteCompactand for the time-of-day branch offormatDateAbsolute, which still renderisDateOnly: falsetokens and labels, so removingcalendar: 'gregory'from either now passes every PowerSearch test; add both back to the loop.
Worth fixing in the same push: the commit message still says the record gains DEC-5 and FR24 and that Lab's MobilePowerSearch uses the new conversions, and neither is true at this head. unixSecondsToISODateTime and isoDateTimeToUnixSeconds are never called and belong with the isDateOnly: false editor change. The timezoneID docs say every date value is read and written in that zone, which is not yet true for isDateOnly: false values.
[Automated review]
| for (const value of [ | ||
| formatDateAbsolute(unixSeconds, 'th-TH', 'UTC'), | ||
| formatDateAbsoluteCompact(unixSeconds, 'th-TH'), | ||
| formatDateAbsolute(unixSeconds, 'th-TH', undefined), |
There was a problem hiding this comment.
This loop no longer covers formatDateAbsoluteCompact, which still renders every isDateOnly: false token (formatTokenValue.ts:186). It also no longer covers the time-of-day branch of formatDateAbsolute, which the label uses. With calendar: 'gregory' removed from either, all PowerSearch tests still pass, and a Thai-locale token or label would show Buddhist-era years. Keep both in the loop:
for (const value of [
formatDateAbsolute(unixSeconds, 'th-TH', 'UTC'),
formatDateAbsolute(unixSeconds, 'th-TH', 'UTC', false),
formatDateAbsoluteCompact(unixSeconds, 'th-TH'),
]) {| return Math.floor(instant / 1000); | ||
| } | ||
|
|
||
| export function unixSecondsToISODateTime( |
There was a problem hiding this comment.
Non-blocking: unixSecondsToISODateTime and isoDateTimeToUnixSeconds have no caller or test in this pull request. They belong with the separate isDateOnly: false editor change. The zone == null branches above cannot run either, because resolveDateZone(…, true) never returns undefined.
| timezoneID: string | undefined, | ||
| isDateOnly: boolean, | ||
| ): string | undefined { | ||
| // An empty string is no zone, as the formatter always read it. |
There was a problem hiding this comment.
Non-blocking (INV29): the second clause narrates history. Suggested: // An empty string counts as no zone.
| * different options threaded through a param, since the two callers want | ||
| * genuinely different shapes, not a parameterization of the same one. | ||
| * The released token text for a value with a time of day: its day in the | ||
| * viewer's zone, as the token has always shown it. |
There was a problem hiding this comment.
Non-blocking (INV29): "as the token has always shown it" narrates history. Suggested: "Token text for a value with a time of day: its day in the viewer's zone."
| type: 'string', | ||
| description: 'Timezone ID for date formatting (e.g. "America/New_York").', | ||
| description: | ||
| 'IANA zone the date values are read and written in: a calendar day shows, edits and stores (as that midnight) in it; unset, a day is its UTC day. E.g. "America/New_York".', |
There was a problem hiding this comment.
Non-blocking: an isDateOnly: false value is not yet read or written in this zone. Its token shows the device's day and its editor stores UTC midnight. Suggested: 'IANA zone a date-only value is shown, edited and stored (as that midnight) in; unset, its UTC day. E.g. "America/New_York".' The dense entry at line 575 needs the same narrowing.
5ec3631 to
79eebb8
Compare
|
/approve-spec 79eebb8 |
There was a problem hiding this comment.
Requesting changes: the date-zone fix matches the current PowerSearch record and its tests are thorough, but one unintended change needs to come out.
PowerSearchToken.tsx:70forwardstimezoneIDinto the time-of-day formatter, so acomponentsToken override that wrapsPowerSearchTokennow shows anisDateOnly: falsevalue intimezoneID("Mar 9, 2024, 7:00 PM" becomes "Mar 10, 2024, 12:00 PM" for a Los Angeles viewer of anAsia/Tokyofield), while the record's Compatibility section says such a value is untouched; passtimezoneIDonly for a date-only value and add that override case toPowerSearchDateZone.test.tsx.
The earlier Gregorian-calendar test gap is fixed. Two optional cleanups: the zone == null branches in powerSearchDateZone.ts cannot run, and one date-only zone assertion in formatFilterValue.test.ts would back the FR25 verification row's "formatter's unit tests".
[Automated review]
| adjustedMaxLength, | ||
| t, | ||
| locale, | ||
| timezoneID, |
There was a problem hiding this comment.
PowerSearch now hands timezoneID to every components Token override, so an override that renders <PowerSearchToken {...props} /> reaches this line with it set. For an operator with isDateOnly: false, formatFilterValue then formats the date and time in timezoneID instead of the viewer's zone: a Los Angeles viewer of an Asia/Tokyo field sees "Mar 10, 2024, 12:00 PM" where the released token showed "Mar 9, 2024, 7:00 PM". The record's Compatibility section says such a value is untouched. Suggested:
operator.value.type === 'date_absolute' && operator.value.isDateOnly === false
? undefined
: timezoneID,…, and edits it there Three readers of one unixSeconds used three zones: the token formatted in the device's zone, the accessible label in timezoneID, and the edit popover's date editor read and wrote the UTC day, never receiving timezoneID. West of UTC a filter opened on the day after the one its token showed, and re-picking that day moved the value a day earlier. A date-only date_absolute value (isDateOnly unset or true), and each absolute range part, is now a calendar day in timezoneID, else the UTC day, on the token, in the label and announcements, in the sheet's rows and value step, and in the editor, and a picked day stores as that zone's midnight; with no timezoneID no stored value changes. The exported PowerSearchToken and a components Token or Editor override receive timezoneID. A value whose operator sets isDateOnly: false keeps its released reading. The record's FR25 implementation-gap notes come off, as the popover now meets them.
79eebb8 to
35dc8d8
Compare
|
/approve-spec 35dc8d8 |
There was a problem hiding this comment.
Recommending approval. The date-zone fix matches the current PowerSearch record (FR25, DEC-5): a date-only value now reads as one day on the token, the label and the editor, a picked day stores as that zone's midnight, and an isDateOnly: false value keeps its released reading, including through PowerSearchToken. The new tests fail on the base and pass here.
Two optional cleanups:
- The changeset says
PowerSearchTokenpreviously "showed the label's date and time", but it never receivedtimezoneID, so it showed a date and time in the viewer's zone; suggested: "where it showed a date and time in the viewer's zone". powerSearchDateZone.tshandleszone == nullat lines 48 and 60, but every caller passes a string, so typingzoneasstringremoves both branches and theplainDateFromDateandplainDateToDateimports.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] PowerSearch: a date-only `date_absolute` value (`isDateOnly` unset or `true`) reads as one day in one zone — on the token, in the accessible label and announcements, and in the edit popover's date editor — and the editor writes the day picked. Before, the token showed the device's day, the label showed a date and a time in `timezoneID`, and the editor read and wrote the UTC day without receiving `timezoneID`, so west of UTC a filter opened on the day after the one its token showed and re-picking that day moved the value a day earlier. Now a date-only value (`isDateOnly` unset or true) is a calendar day in `timezoneID`, else the UTC day: the token shows that day; the accessible label and `formatFilterValue` show that day with no time of day (UTC midnight March 9 in Los Angeles read "Mar 8, 2024, 4:00 PM" and reads "Mar 9, 2024"); the editor opens on it; and a picked day stores as that zone's midnight — with `timezoneID` set this is a different instant from the UTC midnight stored before, so a caller that derived the day from the instant's UTC date reads it in `timezoneID` instead, and a value the old editor stored as UTC midnight under a `timezoneID` west of UTC now reads the day before in the editor on every device, and on the token for a viewer at or east of UTC (UTC midnight March 9 under `America/Los_Angeles` reads March 8 everywhere; a Los Angeles viewer's token and the label already did), the day it would have stored — re-save such values, or read them as UTC days; with `timezoneID` unset no stored value changes. Each absolute `date_range` part is read and written as a calendar day the same way in the range editor. An operator with `isDateOnly: false` is untouched: its token, label and editor read as before. In the sheet presentation the rows and the value step read and write the same day. The exported `PowerSearchToken` and a `components` Token override receive `timezoneID` (a new optional prop on `PowerSearchTokenProps`), and `PowerSearchToken` shows that day too, where it showed the label's date and time. A `[fix]`, not a breaking change: the released popover read one value in three zones, so nothing valid relied on how a day was stored, and `timezoneID` is documented for date formatting. A `components` Editor override and `PowerSearchFilterEditor` receive `timezoneID`. |
There was a problem hiding this comment.
Non-blocking: before this change PowerSearchToken never received timezoneID, so it showed a date and time in the viewer's zone, not the label's timezoneID date and time. Suggested: "and PowerSearchToken shows that day too, where it showed a date and time in the viewer's zone".
| const instant = unixSeconds * 1000; | ||
|
|
||
| return plainDateToISO( | ||
| zone == null |
There was a problem hiding this comment.
Non-blocking: every caller passes resolveDateZone(…, true) or 'UTC', so zone is never undefined here or at line 60. Typing zone as string removes both branches and the plainDateFromDate and plainDateToDate imports.
fix(core): PowerSearch reads a date-only value as one day in one zone, and edits it there
User impact
Anyone editing a
date_absolutefilter in Core PowerSearch's popover from a device west of UTC, and anyone who passestimezoneID. The token showed the device's day, the accessible label showed the day and time intimezoneID, and the editor read and wrote the UTC day, ignoringtimezoneIDentirely (PowerSearch.tsxnever passed it to the popover). In Los Angeles a filter stored as UTC midnight March 9 showed "Mar 8" on its token and opened on March 9 in the editor; a filter at March 9, 7 PM Pacific withtimezoneID="America/Los_Angeles"showed "Mar 9" and opened on March 10; re-picking the day the token showed stored the previous UTC midnight, so the token then read a day earlier again.Problem and solution fit
Why does it occur? Three readers of one
unixSeconds, three zones: the token usedIntl.DateTimeFormatwith notimeZone(device zone),formatFilterValueusedtimezoneID, and the editor usedtoISOString().split('T')[0]andnew Date('YYYY-MM-DD')(UTC).timezoneIDwas threaded to the label only.Why does it harm the task? A filter that reads as one day on its token and another in its editor cannot be trusted or corrected: every "correction" moves it.
Why does that harm matter?
timezoneIDis documented as the zone dates format in. The released behavior did not honor it in the editor, and the record listed the disagreement as a known gap waiting on an owner decision — which the owner has now made (DEC-5).Fix: one module,
powerSearchDateZone.ts, names the zone (timezoneID; else UTC for a calendar day, the viewer's zone for an instant) and converts between an instant and a day or a wall-clock time there with the existingplainDatehelpers.formatDateAbsoluteis the one formatter for the token text and the label;PowerSearch.tsxpassestimezoneIDto the popover (and to acomponentsEditor override;PowerSearchFilterEditorforwards it), which threads it to the value editor and the nested editor's sub-filter editors;DateAbsoluteEditorreads and writes the day in that zone;DateRangeEditorreads and writes its parts as days in that zone.Expected behavior and authority
component:PowerSearchDEC-5 (this PR, decider imdreamrunner, 2026-11-02): adate_absoluteand each absolute range part is a calendar day intimezoneID, else the UTC day; token, label, announcements, rows and editor read that one day; a picked day stores as that zone's midnight. FR25 states it; the known gap on date-only days is resolved into it. TheisDateOnly: falseopen question stays open here and is decided in its own pull request.timezoneIDprop docs ("for date formatting").spec:AST-017/FR5: a correction that restores a documented contract. Classified[fix]pending the owner's call (see Changeset category); the compatibility section of the record and the changeset state the one observable change for a caller that passestimezoneID(the stored instant is that zone's midnight, not UTC midnight). WithtimezoneIDunset, no stored value changes.Smallest restoration
One new module (
powerSearchDateZone.ts, Core-internal, imported by relative path); one formatter signature;timezoneIDthreaded through the popover's existing prop chain, to the sheet's rows and value step, and to thecomponentsToken and Editor overrides, the exportedPowerSearchTokenandPowerSearchFilterEditor; two editors. One optional prop added toPowerSearchTokenProps(timezoneID), no visual change beyond the token showing the right day, no catalog key.timezoneID=""reads as unset, as the formatter always did.Evidence
PowerSearch, jsdom, host zones UTC / Los Angeles / Tokyo / Honolulu ×timezoneIDLA / unset, instant 2024-03-10T03:00Z): token "Mar 9" in LA and Honolulu, "Mar 10" in UTC and Tokyo, in everytimezoneIDcase; editor "March 10, 2024" in every case; picking 03/09/2024 stored 2024-03-09T00:00Z in every case; range editor in LA opened on "Mar 10 – Mar 11" for instants on the evenings of March 9 and 10 Pacific.timezoneID="America/Los_Angeles"token "Mar 9, 2024" and editor "March 9, 2024" under every host zone; withtimezoneID="Asia/Tokyo""Mar 10" on both; with notimezoneIDa UTC-midnight value reads "Mar 9" on both under every host zone; picking March 11 stores 07:00Z (LA, daylight time), 15:00Z the day before (Tokyo), 10:00Z (Honolulu), 00:00Z (UTC and unset); a round trip in LA that moves the day to March 12 and back keeps the instant and the token; range parts "Mar 9 – Mar 10" intimezoneID, UTC days when unset.useTableFiltering) is untouched and its suite passes.PowerSearchDateZone.test.tsx, 30 cases, plus four sheet cases —isDateOnly: falsekept on its released token, label and editor, acomponentsEditor override andPowerSearchFilterEditorreceivingtimezoneID, the western round trip moving the day and back — the accessible label checked through the removal announcement ("Removed Due: on Mar 9, 2024", no time), the range case asserting the write (March 11–12 picked in the calendar store each day's Los Angeles midnight); 17 fail onmain(the 11 that pass are the UTC-host or UTC-zone cases where the old code agreed by accident).Writing rubric results
#+ digits,/pull/,/issues/).isDateOnly: falsequestion stays open, reworded to say what today's rule is.Scope
isDateOnly: falseeditor is split out into its own pull request.isDateOnly: falseeditor is its own pull request.Testing
pnpm exec vitest run packages/core/src/PowerSearch packages/core/src/Table/plugins/filtering packages/core/src/i18n— all pass;PowerSearchDateZone.test.tsx30/30 here (host zones ×timezoneID; token, label, editor, round trip, range parts, Token and Editor overrides,PowerSearchFilterEditor,isDateOnly: falseuntouched), plus four sheet cases (the value step opens on the day intimezoneIDand stores that zone's midnight: Tokyo, Honolulu, unset; acomponentsEditor override in the value step receivestimezoneID); 17 of the popover cases fail onmain.pnpm -F @astryxdesign/core typecheck,typecheck:docs— clean.ASTRYX_STRICT_LINT=1eslint onpackages/core/src/PowerSearch/— 0 findings.Release category: why this is a fix
spec:AST-017FR32 makes a correction[breaking]only when "a valid latest-stable consumer relies on that behavior such that the correction breaks … persisted data". Before this change, no valid consumer could rely on how PowerSearch reads a date-onlydate_absolute.timezoneID(formatDateAbsoluteCompact). The accessible label and the removal announcement format intimezoneIDwith a time of day (formatDateAbsolute). The editor reads and writes the UTC day (toISOString). For a viewer west of UTC, the token shows one day and the editor opens on the next, and re-picking the day the token showed stores the day before it. A consumer "relying" on this relies on the drift itself.timezoneIDis documented as "Timezone ID for date formatting", yet the released token ignores it and the editor never receives it.component:PowerSearchDEC-3 states the one-day-one-zone rule for the sheet and records the popover's date handling as a known gap (FR32's first clause).timezoneID; in this repository only Storybook stories do, and no template, app or package does. WithtimezoneIDunset, stored values don't change, and the token and label now show the UTC day the editor already used. That is a visible correction with no released victim, which FR32 keeps[fix].timezoneIDwhose viewers are in that zone, the token already showed the day in that zone. The editor now opens on that same day, and a picked day stores as that zone's midnight, so reading the stored value in the zone the caller asked for gives the day the person picked. The stored instant changes only for a consumer that reads the value as a UTC day while asking PowerSearch for another zone — the inconsistency being fixed, not a valid reliance.