Skip to content

fix(DateInput, DateTimeInput): the sheet's calendar waits for today, so hydration matches - #10400

Merged
cixzhang merged 4 commits into
mainfrom
fix/date-sheet-today-hydration
Nov 8, 2026
Merged

cixzhang merged 4 commits into
mainfrom
fix/date-sheet-today-hydration

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

User impact

  • Who: anyone who server-renders a page with a DateInput or DateTimeInput that uses presentation="bottom-sheet", when the server's date differs from the browser's. The usual case is a server in UTC and a visitor in another zone near midnight.
  • Before: the closed sheet's calendar is mounted, and it reads today during render: its anchor month, the month scroller's today marker and its heading. React reports a hydration error and re-renders the tree on the client.
  • After: hydration matches the server markup. The closed sheet's calendar renders in the first render after hydration, once the browser's today is known. A person never sees the difference: the sheet is closed while this happens. Client-only apps see no change.

Problem and solution fit

  1. Why the defect occurs: the sheet fields read new Date() during render, and the server and the browser can be on different dates.
  2. Why it harms the task: React throws away the server markup and re-renders the page.
  3. Why that matters: server rendering is a supported mode for every Core component, and a date near midnight is a normal state.

This is the same fix the Calendar and DateRangeInput got: today comes from the shared internal useToday() hook, which is unknown on the server and while hydrating.

Expected behavior and authority

  • spec:AST-013 FR9: SSR-capable components do not read user-agent state during the server render or the client render that hydrates. DateInput and DateTimeInput now cite spec:AST-013/FR9, and list the new test in verified_by.

Smallest restoration

  • TouchDateField and TouchDateTimeField read today from useToday(). The sheet's content renders once today is known. The opening month is stored in the first render that knows today, as Calendar does, so a render after midnight at a month end does not move an open sheet. Reset reads today in its own handler.
  • MonthScroller takes today: PlainDate | null.
  • No new public API, no visual change, no change to an open sheet.

Evidence

  • Before the change: TouchDateToday.ssr.test.tsx fails on main with React's hydration error. It renders the markup on a UTC server at 23:30 on 30 November and hydrates it in a browser whose date is already 1 December.
  • After the change: it passes for both components.
  • Month-end midnight after hydration: the same file opens a hydrated sheet on 30 November, moves the clock to 1 December and re-renders. Before storing the opening month, both sheets jumped to December (red commit); now both stay on November.
  • Real browser: the Calendar today-hydration fixture and its browser spec now cover a sheet DateInput and a sheet DateTimeInput: rendered on 30 November, hydrated on 1 December, opened, they show December with 1 December as today and no recoverable error (spec:AST-013 FR9 verification and FR10). This runs in CI's browser lane.
  • Unchanged path: the DateInput and DateTimeInput suites pass (23 files, 954 tests), including the touch-sheet suites.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run packages/core/src/DateInput packages/core/src/DateTimeInput packages/core/src/Calendar
  • pnpm check:knowledge

…so a server in another zone no longer causes a mismatch

A DateInput or DateTimeInput with presentation="bottom-sheet" keeps its
sheet content mounted while closed, and that content read today during
render: the anchor month, the month scroller's today marker and the
heading. A server and a browser on different dates then render different
markup, and React hydration fails.

The sheet fields now read today through the shared useToday hook: null
on the server and while hydrating. The sheet's content renders once today
is known, and its anchor month is derived until then. Reset reads today
in its own handler.
@vercel

vercel Bot commented Nov 6, 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 8, 2026 6:03am UTC

Request Review

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

astracat-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 8, 2026, 6:34 AM UTC

@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 3edbdfc

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · c676a96

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
DateInput · Storybook 172.9 kB (not measured) · 16.4 kB CSS (not measured) 5,629 (not measured) ✗ · ✓ · ✓
Calendar · Storybook 62.7 kB (not measured) · 9.9 kB CSS (not measured) 1,747 (not measured) ✓ · ✓ · ✓
DateTimeInput · Storybook 195.4 kB (not measured) · 18.1 kB CSS (not measured) 3,581 (not measured) ✓ · ✓ · ✓
1 more component
Component Size LoC Visual · A11y · RTL
PowerSearch 271.2 kB (not measured) · 23.1 kB CSS (not measured) — — · — · —
Visual changes: 2 snapshots in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
DateInput · Cleared Calendar Selection (neutral, dark) before frame after frame diff frame
DateInput · Cleared Calendar Selection (neutral, light) before frame after frame diff frame

Package size: measured; main has no measurement of the merge base to compare yet.

API changes: cli +14 · ~5 · −0 (against the merge base's committed report); core +15 · ~9 · −0 (against the merge base's committed report)

Committed API report behind this build: cli 19 rows, core 24 rows; run pnpm api:report.

43 API changes (advisory)
Package Where Signature Usage
+ cli ./api · Types · type SearchResultEntry deprecated?: ComponentDeprecation | undefined import type {SearchResultEntry} from '@astryxdesign/cli/api'; const x: SearchResultEntry = {deprecated: …}
+ cli ./authoring · Types · interface ComponentDeprecation interface ComponentDeprecation import type {ComponentDeprecation} from '@astryxdesign/cli/authoring'
+ cli ./authoring · Types · interface ComponentIconSlotDoc interface ComponentIconSlotDoc import type {ComponentIconSlotDoc} from '@astryxdesign/cli/authoring'
+ cli ./authoring · Types · interface ComponentIconSlotStateDoc interface ComponentIconSlotStateDoc import type {ComponentIconSlotStateDoc} from '@astryxdesign/cli/authoring'
+ cli ./authoring · Types · interface MultiComponentDoc deprecated?: ComponentDeprecation import type {MultiComponentDoc} from '@astryxdesign/cli/authoring'; const x: MultiComponentDoc = {deprecated: …}
+ cli ./authoring · Types · interface SingleComponentDoc deprecated?: ComponentDeprecation import type {SingleComponentDoc} from '@astryxdesign/cli/authoring'; const x: SingleComponentDoc = {deprecated: …}
+ cli ./doc · Types · interface ComponentBaseDoc deprecated?: ComponentDeprecation import type {ComponentBaseDoc} from '@astryxdesign/cli/doc'; const x: ComponentBaseDoc = {deprecated: …}
+ cli ./doc · Types · interface SubComponentDoc deprecated?: ComponentDeprecation import type {SubComponentDoc} from '@astryxdesign/cli/doc'; const x: SubComponentDoc = {deprecated: …}
+ cli ./doc · Also exported from an earlier entry point · ComponentDeprecation ComponentDeprecation (./authoring) import {ComponentDeprecation} from '@astryxdesign/cli/doc'
+ cli ./doc · Also exported from an earlier entry point · ComponentIconSlotDoc ComponentIconSlotDoc (./authoring) import {ComponentIconSlotDoc} from '@astryxdesign/cli/doc'
+ cli ./doc · Also exported from an earlier entry point · ComponentIconSlotStateDoc ComponentIconSlotStateDoc (./authoring) import {ComponentIconSlotStateDoc} from '@astryxdesign/cli/doc'
+ cli ./template · Also exported from an earlier entry point · ComponentDeprecation ComponentDeprecation (./authoring) import {ComponentDeprecation} from '@astryxdesign/cli/template'
+ cli ./template · Also exported from an earlier entry point · ComponentIconSlotDoc ComponentIconSlotDoc (./authoring) import {ComponentIconSlotDoc} from '@astryxdesign/cli/template'
+ cli ./template · Also exported from an earlier entry point · ComponentIconSlotStateDoc ComponentIconSlotStateDoc (./authoring) import {ComponentIconSlotStateDoc} from '@astryxdesign/cli/template'
~ cli ./api · Functions · function search function search: (query: string, options?: { cwd?: string | undefined; type?: "template" | "component" | "hook" | "theme" | "doc" | undefined; limit?: number | undefined }) => Promise<SearchResponse> → function search: (query: string, options?: { cwd?: string | undefined; type?: "template" | "component" | "doc" | "theme" | "hook" | undefined; limit?: number | undefined }) => Promise<SearchResponse> import {search} from '@astryxdesign/cli/api'; search(…)
~ cli ./authoring · Types · interface MultiComponentDoc theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[] } → theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[]; componentIcons?: ComponentIconSlotDoc[] } import type {MultiComponentDoc} from '@astryxdesign/cli/authoring'; const x: MultiComponentDoc = {theming: …}
~ cli ./authoring · Types · interface SingleComponentDoc theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[] } → theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[]; componentIcons?: ComponentIconSlotDoc[] } import type {SingleComponentDoc} from '@astryxdesign/cli/authoring'; const x: SingleComponentDoc = {theming: …}
~ cli ./doc · Types · interface ComponentBaseDoc theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[] } → theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[]; componentIcons?: ComponentIconSlotDoc[] } import type {ComponentBaseDoc} from '@astryxdesign/cli/doc'; const x: ComponentBaseDoc = {theming: …}
~ cli ./doc · Types · interface SubComponentDoc theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[] } → theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[]; componentIcons?: ComponentIconSlotDoc[] } import type {SubComponentDoc} from '@astryxdesign/cli/doc'; const x: SubComponentDoc = {theming: …}
+ core . · Types · type ComponentIconMap type ComponentIconMap<Variant extends string = IconVariant> = { [Slot in ComponentIconSlotName]?: ComponentIconSlotMap[Slot] extends true ? IconName | null | ComponentIconRequest<Variant> : ComponentIconValue<ComponentIconSlotMap[Slot], Variant> } import type {ComponentIconMap} from '@astryxdesign/core'
+ core . · Types · type ComponentIconRequest type ComponentIconRequest<Variant extends string = IconVariant> = Readonly<{ icon?: IconName | null; variant?: Variant; size?: IconSize }> import type {ComponentIconRequest} from '@astryxdesign/core'
+ core . · Types · interface ComponentIconSlotMap interface ComponentIconSlotMap import type {ComponentIconSlotMap} from '@astryxdesign/core'
+ core . · Types · type ComponentIconSlotName type ComponentIconSlotName = keyof ComponentIconSlotMap & string import type {ComponentIconSlotName} from '@astryxdesign/core'
+ core . · Types · type ComponentIconStaticMap type ComponentIconStaticMap = Partial<Record<ComponentIconSlotName, IconName | null | ComponentIconRequest<string>>> import type {ComponentIconStaticMap} from '@astryxdesign/core'
+ core . · Types · type ComponentIconValue type ComponentIconValue<State, Variant extends string = IconVariant> = IconName | null | ComponentIconRequest<Variant> | ((state: Readonly<State>) => ComponentIconRequest<Variant> | null | undefined) import type {ComponentIconValue} from '@astryxdesign/core'
+ core . · Types · interface DefineThemeInput componentIcons?: ComponentIconMap<ThemeIconEntryVariant<IconVariants, Base>> import type {DefineThemeInput} from '@astryxdesign/core'; const x: DefineThemeInput = {componentIcons: …}
+ core . · Types · interface DefinedTheme __componentIcons?: Partial<Record<string, StoredComponentIconValue>> @internal import type {DefinedTheme} from '@astryxdesign/core'; const x: DefinedTheme = {__componentIcons: …}
+ core . · Types · interface DefinedTheme componentIcons?: ComponentIconStaticMap import type {DefinedTheme} from '@astryxdesign/core'; const x: DefinedTheme = {componentIcons: …}
+ core ./Icon · Also exported from an earlier entry point · ComponentIconMap ComponentIconMap (.) import {ComponentIconMap} from '@astryxdesign/core/Icon'
+ core ./Icon · Also exported from an earlier entry point · ComponentIconRequest ComponentIconRequest (.) import {ComponentIconRequest} from '@astryxdesign/core/Icon'
+ core ./Icon · Also exported from an earlier entry point · ComponentIconSlotMap ComponentIconSlotMap (.) import {ComponentIconSlotMap} from '@astryxdesign/core/Icon'
+ core ./Icon · Also exported from an earlier entry point · ComponentIconSlotName ComponentIconSlotName (.) import {ComponentIconSlotName} from '@astryxdesign/core/Icon'
+ core ./Icon · Also exported from an earlier entry point · ComponentIconStaticMap ComponentIconStaticMap (.) import {ComponentIconStaticMap} from '@astryxdesign/core/Icon'
+ core ./Icon · Also exported from an earlier entry point · ComponentIconValue ComponentIconValue (.) import {ComponentIconValue} from '@astryxdesign/core/Icon'
~ core . · Components · component DateInput prop value?: ISODateString → prop value?: ISODateString | undefined <DateInput value={…} />
~ core . · Components · component DateTimeInput prop value?: ISODateTimeString → prop value?: ISODateTimeString | undefined <DateTimeInput value={…} />
~ core . · Components · component TimeInput prop value?: ISOTimeString → prop value?: ISOTimeString | undefined <TimeInput value={…} />
~ core Theme targets · target code (Code) target code (Code) props [color] → target code (Code) props [color, size] defineTheme({components: {'code': {…}}})
~ core Theme targets · target item (Item) target item (Item) props [align, density] → target item (Item) props [align, density] states [disabled, highlighted, selected] defineTheme({components: {'item': {…}}})
~ core Public attributes · attr data-disabled attr data-disabled (theme reflection on 30 targets) → attr data-disabled (theme reflection on 31 targets) [data-disabled] { … }
~ core Public attributes · attr data-highlighted attr data-highlighted (theme reflection on 1 target) → attr data-highlighted (theme reflection on 2 targets) [data-highlighted] { … }
~ core Public attributes · attr data-selected attr data-selected (theme reflection on 14 targets) → attr data-selected (theme reflection on 15 targets) [data-selected] { … }
~ core Public attributes · attr data-size attr data-size (theme reflection on 55 targets) → attr data-size (theme reflection on 56 targets) [data-size] { … }

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

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

Requesting changes. The hydration fix itself works: the new SSR test fails on main and passes here, and the existing DateInput and DateTimeInput suites still pass. Three things need to change before this can be approved:

  • After hydration, TouchDateField and TouchDateTimeField re-derive the opening month from the clock on every render (TouchDateField.tsx:718-726, TouchDateTimeField.tsx:618-623), so on a server-rendered page an open sheet showing November jumps to December on the first render after local midnight on 30 November, while a client-rendered field stays put; store the anchor in the first render that knows today, as Calendar does, and reword the "then stable for the day" comment.
  • The User impact line's "(or an adaptive presentation that resolves to the sheet)" describes a mismatch that main does not have, because adaptive presentations server-render and hydrate the pointer field and mount the sheet only afterwards, so please drop it.
  • spec:AST-013 FR9's verification row and FR10 ask for a real-browser server render, hydration and post-hydration fixture, so please add both bottom-sheet fields to the existing Calendar today-hydration fixture and browser spec (render on 30 November, hydrate on 1 December, open the sheet, expect December with 1 December as today).

[Automated review]

@cixzhang
cixzhang marked this pull request as ready for review November 6, 2026 22:35
…nth once today is known

After hydration the sheet fields re-derived their anchor month from the
clock on every render, so an open sheet on a server-rendered page jumped
to the next month on the first render after midnight at a month end.
They now store it in the first render that knows today, as Calendar does.
The Calendar today-hydration fixture and browser spec cover a sheet
DateInput and DateTimeInput: rendered on 30 November, hydrated on 1
December, opened on December with 1 December as today.
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 08e64d2

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

Requesting changes: the hydration fix works (the new SSR test fails on main and passes here, and an open sheet now keeps its month across a month-end midnight), but one of the new browser tests fails.

  • The real-browser DateTimeInput case opens the sheet with input[inputmode="none"], which matches both the date and the time combobox, so Playwright's strict-mode click throws before the sheet opens (CalendarTodayHydration.interaction.browser.spec.ts:86); open it with host.getByRole('combobox', {name: 'Starts', exact: true}) instead.

With a narrower opener, both sheet cases pass in Chromium on this branch and fail on main with React's hydration error, so the component change itself holds up. CI's heavy suites have not run on this head yet, which is where this failure would surface.

[Automated review]

…obox name

A DateTimeInput renders a date and a time combobox, so the shared
input[inputmode="none"] opener matched two elements and Playwright's
strict click threw before the sheet opened. The source comments over the
stored opening month are shorter.
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec c676a96

@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: the heavy CI suites are deferred on this head and run in the pre-merge re-run (typecheck and lint pass).

The hydration fix holds up. The new SSR test fails on main with React's hydration error and passes here, and all four real-browser hydration cases now pass in Chromium, including the DateTimeInput sheet opened by its combobox name. An open hydrated sheet keeps its month across a month-end midnight, and the existing DateInput, DateTimeInput and Calendar suites pass.

[Automated review]

@cixzhang
cixzhang merged commit 36c2973 into main Nov 8, 2026
116 of 119 checks passed
@cixzhang
cixzhang deleted the fix/date-sheet-today-hydration branch November 8, 2026 13:04

This branch was successfully deployed

1 active deployment
Preview — c676a961 Deployed Nov 8, 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