Skip to content
Toolkit

ADR-0040: The picker whose calendar was never a calendar — DateTimePicker, and the format the API could not read

Context

Every authoring row since ADR-0035 has been censused before it was designed, on the rule that a remaining row is "a claim to re-check, not a fact." Three turned out to be deletions, one was a kind rather than a name, one was what it said it was, and one had half its stylesheet already shipped in Studio.

DateTimePicker is the seventh, and it is a new shape again: the row was real, the component existed, and it had never worked.

The census

ProbeResult
files named DateTimePicker1 — apps/web/src/components/ui/DateTimePicker.tsx, 227 lines
<DateTimePicker in the working tree5 — DisplayRulesEditor.tsx:235/:241, ApiTokensCard.tsx:189, LinkDetailPage.tsx:246/:247
are all reachable?yes — one routed page, one drawer form, and a targeting editor with two consumers of its own
a storynone exists
a test naming itnone, direct or indirect

Five call sites, three files. The row survives.

Of seven declared props, four were ever passed

ADR-0026 counts what is reachable. value, onChange, label at all five sites and disabled at two. placeholder, error and className have zero call sites, which makes the is-invalid branch, the danger-text error <span> and the className pass-through unreachable code in production — and error is the one that matters, because it is the prop a form would need to report a bad date and no form ever could.

The calendar was laid out two columns wide

Both the seven weekday headings and the up-to-42 day cells were laid out with .form-grid, and .form-grid is:

.form-grid {                              /* patterns.css:97 */
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

Two columns — one below 640px. So a month rendered as a 21-row, two-wide list of buttons under a two-wide row of weekday abbreviations, and on a phone as a single column 42 rows long. .form-grid is defined in exactly one place and overridden nowhere, so there is no rule that ever made this seven columns.

The calendar has never once drawn a calendar.

And the day you chose did not change

The selected day was marked is-active, on a <button class="btn btn-sm btn-block">. Every .is-active rule in the app is compound and none of them names a button:

.chip, .segmented-item, .menu-item, .tabbar-item, .dropzone, .ed-tab, .nav-item, .bottom-tab, .cmdk-item, .admin-nav-item, .nav-sheet-item — seventeen rules, and grep '^.is-active' returns nothing at all.

So clicking a day produced no visible change anywhere on screen. The only feedback was the Apply button ceasing to be disabled.

The panel was not anchored to anything

.popover-panel is position: absolute. Its parent is a bare <div> with no class (DateTimePicker.tsx:117), inside .field, and neither .field, .stack, .form-grid, .card-grid nor .lk-card declares position. On the link detail page there is no positioned ancestor at all, so the panel's containing block is the initial containing block: top: calc(100% + 6px) resolves to one viewport height plus six pixels from the top of the document and left: 0 to the document's left edge.

The one near-exception proves it. .anim-rise is animation: rise … backwards (base.css:333) — fill mode backwards, not both, chosen deliberately so it would not leave a transform behind, with a comment saying so. So during the 0.28s entry animation the panel is anchored to the page wrapper, and after it, to nothing.

Where there is a positioned ancestor the panel is clipped instead. ApiTokensCard sits in Studio's Drawer, whose __body is overflow-y: auto and whose __panel is position: relative with a retained transform; DisplayRulesEditor's other consumer, BiolinkSettingsPanel, sits inside .settings-scroll (overflow-y: auto) inside .card.ed-panel (overflow: hidden, twice).

At every one of the five call sites the calendar was either flung to the corner of the document or clipped out of sight. This is the non-negotiable in AGENTS.md — "If a control ships, it works" — and the fourth shipped-but-dead subsystem the file says there will not be.

The format the server rejects

toISOLocal (DateTimePicker.tsx:27-29) returned `${date}T${time}:00` — no offset, no Z. On LinkDetailPage that string is put into form.scheduled_at and sent verbatim: linkPayloadFromForm does scheduled_at: f.scheduled_at || null (lib/linkForm.ts:117) with no conversion anywhere.

The server binds it to ScheduledAt *time.Time (handlers/links.go:266), decoded by encoding/json, which requires RFC 3339. Run against the picker's own output:

{"scheduled_at":"2026-08-14T12:00:00"}   -> parsing time "2026-08-14T12:00:00" as
                                            "2006-01-02T15:04:05Z07:00": cannot parse "" as "Z07:00"
{"scheduled_at":"2026-08-14T12:00:00Z"}  -> nil

and the handler answers a decode error with writeError(w, http.StatusBadRequest, "Invalid JSON body") for the whole request (handlers/links.go:270-273).

So on the link detail page, setting a start or end date and pressing Save returned 400 and discarded every other edit in the form — the URL, the title, the targeting rules, all of it. ApiTokensCard escaped only because it is the one call site that converts on submit (new Date(expiresAt).toISOString(), ApiTokensCard.tsx:47).

And on the third call site it failed silently, which is worse. DisplayRulesEditor writes into display_rules, which the server reads in services/display_rules.go:61-73:

if t, err := time.Parse(time.RFC3339, ts); err == nil && now.Before(t) {
    return false
}

err == nil && means a string that does not parse is not an error, it is a skipped rule. Go's parser against the same two formats:

2026-08-14T12:00:00        err=true    (rule skipped)
2026-08-14T12:00:00.000Z   err=false → 2026-08-14T12:00:00Z

So every schedule window configured through the targeting editor was silently ignored in production traffic: a link set to go live next week was live immediately, and one set to expire never expired. Nothing surfaced, because the only code path that could have raised an error treats the failure as absence. It is the same defect wearing its other face — an unparseable instant is a 400 where the field is typed, and nothing at all where it is free-form JSON — and the same change fixes both, since toISOString() output parses as RFC 3339.

Nothing in the control had a name

grep -n "aria-|role=|id=|htmlFor|tabIndex|onKey" over the whole file returns zero hits. The label prop rendered a <span class="small medium muted"> — not a <label>, no htmlFor, over a <button> with no id — so all five pickers were announced by their own value or the placeholder. That is the defect ADR-0032 found 32 times behind Input, and ADR-0035, ADR-0038 and ADR-0039 each recorded once since: the fifth time, and the same answer — labelling is Field's.

With it: ten unnamed month arrows (icon-only, no aria-label), five unnamed time inputs (<label> with no htmlFor over an <input> with no id), no aria-expanded, no role on the panel, and no keyboard model of any kind — no Escape, no arrow keys, and up to 42 day buttons as 42 separate tab stops, injected into the Drawer's focus trap at one site.

Decision

Author DateTimePicker into Studio as a portalled anchored dialog over a real month grid; convert all five call sites to Field + DateTimePicker; change the emitted value to an ISO-8601 instant; delete the app's.

Like ADR-0038 and ADR-0039 this is an authoring and a conversion on one commit, and the app component is removed rather than kept, because the app is left owning nothing.

One export, not two

ADR-0027's question — what is the real counterpart? — turns up nothing: Studio exports no Calendar, DatePicker, DateField or TimeField, and DESIGN.md says nothing about date or time input at all. A grep for date, time, calendar, picker, month or day across its 618 lines returns one hit, "Esc unwinds one layer at a time". So this component's anatomy is precedent-setting rather than specified.

A separate Calendar export was considered and rejected on ADR-0035's rule: every call site wants a date and a time, so a Calendar would ship with no consumer, and an authored thing with no call site is what three of this queue's rows turned out to be. The month grid stays internal until something asks for it alone.

The panel is portalled, and that is not a preference

Combobox portals because its one call site sits inside overflow-y: auto (ADR-0037); MultiSelect inherited the reasoning. Here four of the five call sites sit inside a scrolling or overflow: hidden ancestor and the fifth has no positioned ancestor at all, so an in-place panel is wrong in two different ways at once. useAnchoredPosition measures the trigger and the panel is createPortaled to <body>, which answers both.

The --z-overlay limit MultiSelect records applies unchanged and is not widened here: the panel sits at --z-overlay (1000), and the one call site inside a modal surface is inside Studio's own Drawer, which is also --z-overlay and also portalled, so DOM order decides and the panel wins. Cardsite's --z-modal (1050) is spent only by shell chrome (shell.css:815, :829, :1114), so no app surface above the ladder is involved. This clears open item 5 for this component and for no other — it is the same narrow clearance ADR-0037 and ADR-0038 recorded, not a general answer, and Select still blocks on it.

The value is an instant

onChange emits Date.prototype.toISOString() and value accepts anything new Date() parses. The panel shows and edits local wall-clock; only the wire format is UTC.

This is the fix for the 400 above, and it is the right shape independently: the column is TIMESTAMPTZ (migrations/000013) and the Go field is *time.Time, so the wire type is an instant and always was — the app had never emitted one. ApiTokensCard's own conversion is now a no-op that still holds (new Date(iso).toISOString() is the identity on an ISO instant), so no call site needed a compensating change.

Six raises over what the app had

ADR-0019: the authored component is better than the thing it replaces, and the difference is stated rather than absorbed.

  1. The calendar is a calendar. A <table role="grid"> with table-layout: fixed and seven columns, padded to whole weeks so every row holds seven cells. Fixed columns rather than auto, so a three-character weekday abbreviation in another locale cannot widen one column against the others — which is the whole difference between a calendar and a list.
  2. Choosing is visible, and today is a different mark. The chosen day takes an --accent fill; today takes an --accent-line ring. Two marks, because a day can be both at once and one of them still has to read.
  3. There is a keyboard model, and the grid is one tab stop. ←/→ a day, ↑/↓ a week, Home/End the week's ends, PageUp/PageDown a month, Shift+PageUp/PageDown a year, Enter chooses, Escape closes and returns focus — the APG date-grid map. The tab stop roves, which is DESIGN.md's rule for collections and the rule MultiSelect and CodeEditor each have an open item for breaking. Walking off the end of a month moves the view with the focus, and addMonths clamps rather than rolling over: new Date(2026, 0, 31) stepped a month is 31 February, which the Date constructor silently normalises to 3 March, so an unclamped PageDown skips February entirely.
  4. Everything is named. The trigger by Field's <label for> — it is the tab stop, so id, aria-describedby and aria-invalid land on it; the dialog by label, required for Popover's reason; each day by its full date rather than a bare number; both month arrows; and the time field by a real <label htmlFor>. Twenty controls that had no accessible name now have one.
  5. The panel is anchored and unclipped, per the section above, and Escape stops at this control rather than closing the Drawer behind it.
  6. The dates are the reader's. Month and weekday names come from Intl.DateTimeFormat rather than two hard-coded English arrays, and the trigger no longer pins 'en-US' while the page around it formats with the reader's locale — two dates on one screen disagreed. The weekday formatters pin timeZone: 'UTC' against their synthetic anchor date, because a synthetic date fed to a local-zone formatter lands on the previous day west of Greenwich and rotates the entire weekday header by one.

Three props did not survive, and one behaviour deliberately changed

label and error are Field's, on ADR-0032's precedent; placeholder survives, and none of the three had a call site as an error carrier.

The Apply button is gone. Choosing a day commits immediately, as MultiSelect commits each toggle. The old two-step existed to make a selection that nothing drew survive until a button confirmed it — with the chosen day now visibly chosen, a confirm step is one press between the user and the thing they already did. Recorded rather than absorbed.

Consequences

The app CSS: one rule died, and one that looks identical did not

ADR-0021. Counted with ADR-0037's method, re-implemented for this item and validated by reproducing all twenty-one of ADR-0039's published numbers exactly before being used for anything — which is also how the method's *.stories.tsx exclusion was rediscovered, .ic-btn coming back 6 against a published 5 until a story stopped counting as a consumer (ADR-0036).

classbefore → afterclassbefore → after
panel-w-lg1 → 0center86 → 85
popover-panel2 → 1ink112 → 110
is-focused2 → 1mt-314 → 12
field3 → 2row108 → 107
is-invalid4 → 3grow53 → 51
btn9 → 7shrink-032 → 31
btn-sm7 → 5tiny99 → 97
btn-block3 → 2small440 → 436
btn-outline2 → 1medium161 → 157
btn-primary4 → 3muted370 → 366
form-grid67 → 65faint128 → 124
control57 → 55danger-text46 → 45
menu6 → 5row-between31 → 29
mb-120 → 19mb-239 → 38
mb-334 → 33

Only .panel-w-lg is deleted, and it is the clean case the last three conversions did not get: DateTimePicker.tsx:144 was its sole emitter anywhere — app, tests, stories, preview/current-design.html and .archives/removal-safe/ — so unlike .checkbox (ADR-0036), .check-tile (ADR-0038) and .code-editor-* (ADR-0039) there was no preview card holding it up.

.panel-w-md sits directly above it with zero emitters too, and had none before this item, so it is pre-existing dead rather than this conversion's to delete — the .framed-head precedent. It is recorded, not swept. .panel-w-sm keeps one emitter, ColorPicker.

.popover-panel and .is-focused are now down to one emitter each, ColorPicker, and both die with it. .field falls to two and needs Select as well as ColorPicker; and even then it does not go, because preview/current-design.html emits .field three times and links the app stylesheet — the ADR-0036 trap, on a class the session file had listed as one conversion from dead.

Types: DateTimePicker is the 38th of Studio's 116 React exports to be typed

Twenty deliberately wrong calls, of which seventeen are rejected and three cannot be. The seventeen: a missing label, a Date value, a numeric value, a DOM-event onChange, type="submit", children, an object className, a string disabled, a numeric locale, an element clearLabel, a numeric timeLabel, a boolean placeholder, a min that does not exist, the two retired props, a ref — the house gap ADR-0033 records — and defaultValue. The probe was mutation-checked (one illegal call made legal, its @ts-expect-error correctly reported unused) and deleted before commit.

The three are aria-expanded, aria-controls and aria-haspopup, and their failure is ADR-0038's finding reproduced exactly: TypeScript cannot reject a hyphenated JSX attribute, so an Omit of one is unreachable and listing them is documentation rather than enforcement. The runtime guarantee is the rest-first spread, and a test pins it — the same answer MultiSelect reached, arrived at here by the probe failing rather than by copying it.

The tests: 157 assertions across 72 tests, 67 mutations, 64 killed

apps/web/src/components/DateTimePicker.test.tsx. The component had zero coverage before, of any kind — and so did the branch that renders two of its call sites: DisplayRulesEditor.test.tsx mounts the editor nineteen times across eighteen tests and never once turns scheduling on, so DisplayRulesEditor.tsx:233-256 was untested in full. That is the open item ADR-0037 raised and this item was told to close; it is closed by the component's own suite rather than by the editor's, and the editor's branch is still untested. Recorded as still open, narrowed to the Switch.

The mutation pass found four real holes in the tests, and one of them was an assertion of the exact kind the Method warns about:

  • expect(within(panel).queryByRole('button', { name: /14 August 2026/i })?.getAttribute('data-selected')).toBeUndefined() passed against a component that had not re-synced at all, because the lookup found nothing and the optional chain returned undefined — the assertion could not fail. It is a count of [data-selected] now.
  • Nothing asserted that a day-equality test compares the year, so dropping that term survived: every fixture stayed inside one year, and a month grid only ever shows one. A picker holding 14 August 2025 would have lit 14 August 2026 up.
  • The reset-on-disabled effect was untestable against the !disabled term in shown, each masking the other. The new assertion is that lowering the flag does not bring the panel back, which only the effect can satisfy.
  • The re-sync test was strengthened onto the time field, the only place a guarded sync shows once the value is empty.

The harness lied twice before it told the truth, which is worth as much as the result. It first reported fourteen survivors; running one of them by hand killed it. The cause was that overlays.jsx holds five other components that share whole lines with this one — if (e.key !== 'Escape') return; is in Popover 300 lines earlier — and a bare String.replace takes the first occurrence, so those mutations were landing on a different component and reporting a false survivor here. Scoping the edit to the component's own region fixed the JSX; the same bug then surfaced in the CSS, where box-shadow: 0 0 0 3px var(--error-soft) appears three times. This is the same shape as the harness bug ADR-0038 recorded, found again because the survivors were checked by hand rather than believed.

The three survivors that remain are not test gaps:

  • shown = open && !disabled → shown = open. The trigger carries the DOM disabled attribute and the reset effect clears open, so the term is belt-and-braces behind two other guards, and the frame in which it matters is before an effect RTL has already flushed. Same category as ADR-0038's recorded survivor.
  • The useState initialiser for cursor. The mount effect sets it from value immediately, so initialising from today instead survives every assertion — the difference is one pre-paint frame showing the wrong month, which jsdom cannot see.
  • preventDefault on Enter and Space at the trigger. A real <button> fires a click from both, which would toggle the panel straight back shut, so the handler stops it — but user-event does not synthesise that click, so dropping the call passes all three of the tests written for it. Kept because the browser behaviour is real, and the test says so rather than claiming coverage it does not have.

And two more survived only because this container runs UTC: dropping timeZone: 'UTC' from the weekday anchor, and reading the clock with toISOString().slice(11, 16) instead of local getters. Both are killed under TZ=Asia/Tokyo and TZ=America/Los_Angeles respectively, checked explicitly, and the whole suite was run green under five zones including Pacific/Kiritimati — so the tests are sound and it is the environment that cannot tell the difference. Worth stating plainly: a green suite here is weaker evidence about time zones than it looks, and the fixture is built from local parts rather than parsed from a string for that reason.

The i18n ratchet rose, and the rise is committed rather than engineered away

1969 → 1971. The arithmetic: +5, because each call site now writes label twice — once on Field, which draws the visible <label for>, and once on DateTimePicker, which names the role="dialog" panel. Those are two accessible names for two elements and the counter rightly sees both. −3, because Time, Clear and Apply were JsxText in the archived component; the first two are now prop defaults inside studio/packages/react, which the counter does not read (open item 8, the ratchet-scope gap), and Apply is gone with its button.

The alternative was naming the dialog through a prop the counter does not watch, which is hiding user-facing English from the ratchet to keep a number still — the failure mode the Kbd baseline note records, and the second time this workstream has declined it. The real fix is Field exposing the id of the label it already renders so the dialog can point at it with aria-labelledby and the string is written once. That is a Field change and it is on the open-items ledger.

An adversarial pass found nine more, and five were fixed before landing

ADR-0038's precedent: the pass is run against the finished diff, and what it finds is fixed or recorded, not argued with. Five were real enough to change the component or the tests on the same branch:

  1. The suite was a time bomb. One test rendered with no value — so the panel opens on the real current month — and then looked up a day by name, Monday, 3 August 2026. It passed only in the month it was written. npm run verify would have gone red on 1 September with no code change. The day is picked by position now.
  2. Clearing the time field committed midnight. <input type="time"> fires change with '' the moment a user backspaces over the segments to retype, and Number('') || 0 is 0 — so the picker emitted T00:00 for a field the user was halfway through editing, and the controlled round-trip then refilled the box they had just emptied. A token expiry of 17:45 became midnight if they hesitated. An incomplete time is a draft now, exactly as a day-less time already was. The test that ran straight through this defect read only the last onChange call; it asserts that no call anywhere carries midnight.
  3. Paging the month stole focus into the grid. Both header buttons went through the same move() as the arrow keys, which pulls focus to the cursor day. A keyboard user pressing Enter on Next month to walk from August to November got September and a focused day cell — and their second Enter chose a date instead of paging. Paging and moving are two functions now, and DESIGN.md's roving rule says so.
  4. Tab walked out of an open panel. The panel is portalled to the end of <body> with no trap, so Tab from the last control left the visible document order and stranded an open calendar over the surface behind it — inside a Drawer at one call site. Tab closes and returns focus to the trigger, which is SelectBox's documented house rule.
  5. The value and placeholder classes could be swapped undetected. The layer assertions proved the two rules exist; nothing proved the markup asked for the right one, so inverting them — a chosen date in placeholder grey, the placeholder in primary ink — passed every test. That is ADR-0023 run in one direction only, and it is the direction the repository still has no gate for.

Two more were untested rather than wrong (onKeyDown composition, and preventDefault on the grid keys, without which every arrow press scrolls the document out from under a position: fixed panel that re-measures on scroll). Both now have tests, and all eight fixes were mutation-checked.

The pass also cost a correction to this ADR: the 400 above is not the whole story, and the display_rules paragraph is there because of it.

What is not fixed here

  • The ADR-0023 completeness gate still does not exist. This component emits sixteen class names and nothing in the repository checks that the layer the app imports defines them. The enumeration was done by script against the built component layer and pinned by a test — and E7 caught one for free on the way: .lk-datetime__pad was named in the markup before it had a rule, the same defect CodeEditor committed and caught inside one sitting. E7 checks the full bundle, so it catches the spelling but not the layering; the mechanical form ADR-0023 proposed is still the highest-value gate not built.
  • The scheduling branch of DisplayRulesEditor is still untested. Its two pickers are covered by this component's suite; the Switch that reveals them, and the editor's own composition of the three, are not.
  • The chosen day is not announced. aria-selected sits on the <td role="gridcell"> while the roving tabindex and the focus sit on the nested <button>, whose only selection marker is data-selected — a styling hook with no semantics. Today is announced, via aria-current="date"; the user's own selection is not. APG puts focus and aria-selected on the same object, and the fix is structural.
  • The week starts on Sunday in every locale. locale moves the names and the formatted value and nothing else. The type and the source comment now say so; Intl.Locale#getWeekInfo().firstDay is the fix.
  • A wall-clock time that does not exist normalises forward. 02:30 on a US spring-forward day becomes 03:30, and the round-trip rewrites the time field to match with no explanation. The date arithmetic itself is DST-safe — addDays and addMonths are local-midnight component arithmetic, checked across a transition — so this is the only hole.
  • There is no min/max, so nothing stops an end date before its start date. Four of the five call sites are start/end pairs and none of them constrains the other. That is a call-site change as much as a component one, and it is recorded rather than widened into here.
  • DisplayRulesEditor pairs the pickers with a TimezonePicker that neither of them reads. A schedule expressed as a UTC instant and a zone chosen separately are two different models of the same intent, and which one the server honours is a product question ADR-0037 already touched.
  • docs/API.md:891 still maps the datetime field kind to this component, and BlockSettingsForm.tsx:199 still renders a bare <input type="datetime-local"> for it — one of seven native datetime inputs that coexist with the picker. Same shape as the four timezone inputs ADR-0037 found; a consistency sweep, not this item's.

Source: docs/decisions/0040-the-picker-whose-calendar-was-never-a-calendar.md

Library