Repository navigation
fix(DateTimeInput): open the time list on the first click when React owns the document root - #11776
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
… line Maintainer edit on the contributor's fix: - Replaces the removed unmount-watcher test with two cases for the new mechanism: unmounting before the deferred frame cancels the show, and a press that never became a click does not stop a later press from opening the list. - The changeset credits the pull request's author. - component:DateTimeInput FR7's verification row names the document-root case. Co-authored-by: bezabyte <[email protected]>
|
/approve-spec a26f827 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The ci:run label is set, but the CI, Lint and CLI Smoke Test runs for this head still need a maintainer's approval to start. The fix itself checks out: the time list now opens on the first click when React's root is the document, an unmount cancels a pending show, and the new tests fail on the base and pass here.
- Non-blocking: the comment on the Alt+ArrowDown path in
DateTimeInput.tsx(lines 1590-1592) still says a leftover press flag holds every later open "hostage to the next click anywhere"; with the document listeners gone it only delays a keyboard open by one frame, so it could read "A keyboard open is never mid-click. Clear the flag a press without a click can leave, so the list shows at once." - Non-blocking:
BaseTypeaheadkeeps the same document-click deferral and shows the same problem under a document root (a click on the still-focused input after Escape does not reopen its list); a follow-up issue would keep the two components in step.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim (changeset): the first pointer click opens the time options when the field is mounted through a React root on the document. Verified: the new test fails on the base and passes on the head.
- Claim (changeset): the deferred show belongs to the field and an unmount cancels it, so a click cannot carry into the next interaction. Verified:
DateTimeInput.tsx:1255-1267and:1428-1433; the unmount test fails on the base and passes on the head. - Claim (changeset): a patch release of the core package. Verified: no public API change.
- Claim (description, before): a press set a flag and added one-shot document click listeners, and under a document root the click handler's listener missed its own click and ran on a later one. Verified against the base code and a document-root reproduction.
- Claim (description, after): the press only records the flag, the click clears it and shows the list on the next frame, and unmount cancels that frame. Verified:
DateTimeInput.tsx:1275-1277,:1428-1433,:1265-1267. - Claim (description): the visual UI is unchanged. Verified: no markup or style change.
- Claim (description): the regression test mounts the field in an isolated document owned by a React root and checks the first click. Verified:
DateTimeInput.test.tsx:2630. - Claim (description): the focused test, ESLint, Prettier, the core typecheck, check:sync and check:changesets pass. Verified; the whole DateTimeInput test file passes here (216 of 216, the Korean locale case included).
- Claim (description): check:repo passes. Verified for every step except three that need a git working tree.
- Claim (description): closes the linked issue. Verified: the change removes the mechanism the issue reports.
- File
.changeset/datetime-document-root-click.md: clear. - File
docs/specs/components/DateTimeInput/DateTimeInput.spec.md: clear (verification-row line). - File
packages/core/src/DateTimeInput/DateTimeInput.tsx: clear, with one non-blocking stale comment. - File
packages/core/src/DateTimeInput/DateTimeInput.test.tsx: clear.
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The ci:run label is set, but the CI, Lint and CLI Smoke Test runs for this head still need a maintainer's approval to start. The fix checks out: the time list opens on the first click when React's root is the document, an unmount cancels a pending show, and the new tests fail before the change and pass with it.
- Non-blocking: the title "open time list on first click" leaves out the document-root condition your changeset states; adding "under a document root" would make the squash commit match the release note.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Changeset: the time options open on the first pointer click under a React root on the document. Verified: the new document-root test fails before the change and passes with it.
- Changeset: the deferred show belongs to the field and is cancelled on unmount, so no click carries into a later interaction. Verified: the unmount test fails before and passes after, and no document listener remains.
- Description: the change fixes the first-click miss under a document root. Verified; the word "regression" is inaccurate, since the listener-based deferral is as old as the preset list.
- Description: before, a press installed one-shot document click listeners that missed the current click and ran on a later one. Verified in the base code and with a same-document check, where the list opens only on a later click elsewhere.
- Description: the press handler only records the press, and the click handler clears it and shows the list on the next animation frame. Verified in
DateTimeInput.tsx(lines 1275-1277 and 1428-1433). - Description: the frame belongs to the field and is cancelled on unmount. Verified in
DateTimeInput.tsx(lines 1257-1267) and by the unmount test. - Description: the visual UI is unchanged. Verified: no markup or style changes.
- Description: a test mounts the component in an isolated document owned by a React root and checks that the first click opens the list. Verified: it fails before the change and passes with it.
- Description: lint, Prettier, the Core typecheck and the sync, changeset and repository checks pass. Verified, except the repository check's executable-bit step, which needs a git checkout.
- Description: the DateTimeInput test file passes apart from one Korean locale assertion in the author's runtime. Consistent: all 216 tests pass here, that assertion included.
- Description: closes the linked issue. Verified: the issue reports this bug.
- File
packages/core/src/DateTimeInput/DateTimeInput.tsx: clear. - File
packages/core/src/DateTimeInput/DateTimeInput.test.tsx: clear. - File
docs/specs/components/DateTimeInput/DateTimeInput.spec.md: clear (a test name in the verification row). - File
.changeset/datetime-document-root-click.md: clear.
|
/approve-spec 86cc170 |
|
Thanks for this! I ran an independent check on head 86cc170: Verdict: approve, with one small fix suggested. Under a React root on the document, the time list now opens on the first press, a press elsewhere afterwards opens nothing, and no listener outlives its press. One gap: two clicks before a frame (a double-click on a busy main thread) schedule two frames and keep only the second id, so unmounting leaves the first frame to call What I ranScratch clone, Node 24.22.1,
Gap: a second deferred show overwrites the first frame's id
Minimal repro (beside it('cancels every deferred show when the field unmounts', () => {
const frames = new Map<number, FrameRequestCallback>();
let next = 0;
const req = vi.spyOn(window, 'requestAnimationFrame')
.mockImplementation(cb => { next += 1; frames.set(next, cb); return next; });
const can = vi.spyOn(window, 'cancelAnimationFrame')
.mockImplementation(id => { frames.delete(id); });
try {
const {unmount} = render(
<DateTimeInput label="Meeting" value={'2026-03-15T09:00' as ISODateTimeString}
timeOptionInterval={60} onChange={() => {}} />,
);
const time = screen.getByLabelText('Meeting time');
fireEvent.pointerDown(time); fireEvent.click(time, {detail: 1});
fireEvent.pointerDown(time); fireEvent.click(time, {detail: 2});
unmount();
expect(frames.size).toBe(0); // 1 on 86cc17030
} finally { req.mockRestore(); can.mockRestore(); }
});Fix: if (timePointerActiveRef.current) {
timePointerActiveRef.current = false;
+ cancelTimeShowFrame();
timeShowFrameRef.current = requestAnimationFrame(() => {
...
}, [
+ cancelTimeShowFrame,
hasTimeOptions,With that applied, Notes (non-blocking)
|
# Conflicts: # docs/specs/components/DateTimeInput/DateTimeInput.spec.md
|
/approve-spec 2ba365a |
There was a problem hiding this comment.
Changes requested: the first-click fix under a document root is right and proven red-first, but a second click inside the same frame leaves a deferred show that unmount never cancels.
- Miss: in
showTimeOptions, a second press's click assigns a newrequestAnimationFrameid overtimeShowFrameRef.currentwhile the first frame is still pending, so two clicks inside one frame leave two frames pending and the unmount Effect cancels only one, leaving the other to callshow()for a field that is gone — the case the changeset says cannot happen — which acancelTimeShowFrame()call before the schedule, added to the dependency list, closes. - Miss: the unmount test's comment "Every frame the field asked for is cancelled, so none runs" sits above
expect(frames.size).toBeLessThan(pending), which passes while one frame survives, so tighten it toexpect(frames.size).toBe(0)once that cancel is in place.
Measured with requestAnimationFrame and cancelAnimationFrame mocked: one click leaves one frame pending and none after unmount, two clicks leave two pending and one after unmount, and with the cancel added it is one pending and none after unmount with the DateTimeInput suite still green. Everything else holds up: the new document-root test fails before the change and passes with it, the element-root timing is unchanged, and lint, Prettier, the Core typecheck and the sync, changeset and knowledge checks all pass here.
- Non-blocking: the title leaves out the document-root condition the changeset states, and the description calls a long-standing defect a regression.
- Non-blocking:
BaseTypeaheadkeeps thedocument-click deferral this change replaces, so the two fields now defer a press-time show two different ways.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Changeset: the time options open on the first pointer click under a React root on the document. Verified: the new document-root test fails at the base and passes at the head.
- Changeset: the deferred show belongs to the field and is cancelled when the field unmounts, so a click cannot be carried into the next interaction. False for two clicks inside one frame, as the first finding shows.
- Description: before, a press installed one-shot
documentclick listeners that the current click dispatch had already passed. Verified in the base source and by a base probe, where an element root opens on the first click and a document root does not. - Description: the press handler only records the press, and the click handler clears the flag and shows the list on the next animation frame. Verified at
DateTimeInput.tsx:1265-1267and:1418-1426. - Description: the frame belongs to the field and is cancelled on unmount. Verified for a single pending frame, not for one a second click replaced.
- Description: the visual UI is unchanged. Verified: no markup or style change, and the API generator reports no surface change.
- Description: "regression". Inaccurate: the listener-based deferral is as old as the preset list, as the linked issue also says.
- Description: lint, Prettier, the Core typecheck and the sync and changeset checks pass. Verified here, with the knowledge check too; the repository check was not run, since its steps need a git checkout.
- Description: the DateTimeInput test file is otherwise clean apart from one Korean locale assertion in the author's runtime. Consistent: all 216 tests in that file pass here, that assertion included.
- Description: closes the linked issue. Verified: the issue reports this defect.
packages/core/src/DateTimeInput/DateTimeInput.tsx: the first finding.packages/core/src/DateTimeInput/DateTimeInput.test.tsx: the second finding; the document-root case and the later-press case are sound.docs/specs/components/DateTimeInput/DateTimeInput.spec.md: clear, a test name added to the FR7 verification row..changeset/datetime-document-root-click.md: its second sentence overstates the cancel, as the first finding says.
…ding time-list show
|
/approve-spec 12ccec6 |
There was a problem hiding this comment.
Approved. CI, Lint and the CLI smoke test have run on this head and pass. The time list opens on the first click when React's root is the document, a second click in the same frame replaces the pending show, and no deferred show survives an unmount; the new document-root and unmount tests fail before the change and pass with it. Thanks for linking #13120 for the BaseTypeahead follow-up; nothing else is needed here.
Claims and files checked
Review mode: same-head; reason: none
- Changed rules (0): none.
- Changeset: the time options open on the first pointer click under a React root on the document. Verified: the document-root test (
DateTimeInput.test.tsx:2630) fails before the change and passes with it, and CI passes it on this head. - Changeset: the deferred show belongs to the field and is cancelled on unmount, so a click cannot carry into the next interaction. Verified: one pending frame, replaced by a second click (
DateTimeInput.tsx:1420-1426) and cancelled on unmount (:1257); nodocumentlistener remains. - Description: the defect has been present since the preset list's first version. Verified: that first version already deferred the show through one-shot
documentclick listeners. - Description: before, a press installed one-shot
documentclick listeners that a document-rooted click had already passed, so the first click opened nothing and the leftover listener ran on a later click. Verified in the base source and by the document-root test failing on the base. - Description: the pointer handler only records the press, and the click clears it and shows the list on the next animation frame. Verified at
DateTimeInput.tsx:1265-1267and:1418-1426. - Description: the frame belongs to the field and is cancelled on unmount. Verified, including two clicks in one frame (
DateTimeInput.test.tsx:2702-2712). - Description: the visual UI is unchanged. Verified: no markup, style or public API change; the two calendar frames the visual report flags move because of a calendar line-height change on
main, not this change. - Description: a test mounts the component in an isolated document owned by a React root and checks the first click opens the list. Verified at
DateTimeInput.test.tsx:2630. - Description: lint, Prettier, the Core typecheck and the sync, changeset and repository checks pass. Consistent: Lint and typecheck pass in CI on this head; the repository check was not reproduced.
- Description: the DateTimeInput test file is otherwise clean apart from one Korean locale assertion in the author's runtime. Consistent: CI passes all 216 tests in that file on this head.
- Description: closes the linked issue. Verified: the issue reports this defect and suggests this fix.
- Description:
BaseTypeaheadstill defers through a one-shotdocumentclick listener, and #13120 tracks moving it to this pattern. Verified:BaseTypeahead.tsx:1180-1190and:2435-2442keep that deferral, and #13120 is open and proposes exactly that move. packages/core/src/DateTimeInput/DateTimeInput.tsx: clear.packages/core/src/DateTimeInput/DateTimeInput.test.tsx: clear; removing the new cancel makes the unmount test fail.docs/specs/components/DateTimeInput/DateTimeInput.spec.md: clear; a test name added to the FR7 verification row..changeset/datetime-document-root-click.md: clear; matches the change.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DateTimeInput · Storybook | 236.2 kB (−66 B) · 20.7 kB CSS (0) | 3,710 (−9) | ✗ · ✓ · ✓ |
Visual changes: 2 snapshots in 1 component
A change is a question for the reviewer, not a failure.
| Component · story | Before | After | Diff |
|---|---|---|---|
| DateTimeInput · Cleared Calendar Selection (neutral, light) | ![]() |
![]() |
![]() |
| DateTimeInput · Cleared Calendar Selection (neutral, dark) | ![]() |
![]() |
![]() |
Inheritance lookup failed: /actions/artifacts/14896267756/zip: HTTP 503.
Package size: @astryxdesign/core 8.03 MB packed (−461 B); no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
|
/approve-spec ebda0bc |
There was a problem hiding this comment.
Approved pending CI: the CI, Lint and CLI smoke-test runs for this head are still in progress and must pass before merge.
The time list now opens on the first click when React's root is the document, and the pending show is a single frame the field owns, so a second click replaces it and unmounting cancels it. The earlier request about a second click overwriting the pending frame is resolved.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Claim (changeset): the first pointer click opens the time options under a React root on the document. Verified:
DateTimeInput.tsx:1421-1429and the test "opens on the first pointer click when React owns the document root". - Claim (changeset): the deferred show belongs to the field and is cancelled on unmount, so no click carries into the next interaction. Verified:
DateTimeInput.tsx:1250-1260and:1425; test "cancels a deferred show when the field unmounts before its frame". - Claim: the defect has existed since the preset list's first version. Verified: the change that added
timeOptionIntervalalso added both one-shot document click listeners. - Claim: before, a press set a flag and installed one-shot document click listeners, and under a document root the listener added during the click missed that click. Verified against the removed code and the DOM dispatch order.
- Claim: after, the pointer handler only records the press and the click handler schedules the show on the next frame, cancelled on unmount. Verified:
DateTimeInput.tsx:1268-1270,:1421-1429,:1258-1260. - Claim: the visual UI is unchanged. Verified: no markup, style or theme change.
- Claim: the new test mounts the field in an isolated document owned by a React root. Verified:
DateTimeInput.test.tsx:2685-2728. - Claim: lint, formatting, typecheck, sync, changeset and repository checks and the full test file pass in the author's environment. Unverified here; the CI runs now in progress cover them.
- Claim: closes #11763. Verified: the issue reports this exact defect.
- Claim: follow-up #13120 tracks BaseTypeahead's remaining one-shot document listener. Verified:
BaseTypeahead.tsx:1183-1193. - File
packages/core/src/DateTimeInput/DateTimeInput.tsx: clear. - File
packages/core/src/DateTimeInput/DateTimeInput.test.tsx: clear. - File
docs/specs/components/DateTimeInput/DateTimeInput.spec.md: clear. - File
.changeset/datetime-document-root-click.md: clear.
|
🤖 (Posted by Cindy's agent.) Merged, thank you @bezabyte! When React renders the whole document, the first click on a DateTimeInput's time field now opens the time list, where before it needed a second click. A maintainer brought the branch up to date with main, with your authorship kept. It ships in the next release, with you credited, and thanks for your patience while it waited. |






What changed
Fixes a DateTimeInput time-list defect, present since the preset list's first version, when the component is mounted through a React root on
document.Before
A pointer press set a flag and installed one-shot
documentclick listeners. With React's event delegation on the document root, the field's click handler could install that listener after the document had already passed the listener's position in the current click dispatch. The first click therefore did not open the time list; the leftover listener ran on a later click instead.After
The pointer handler only records that the press is active. The click handler clears that flag and schedules the popover show on the next animation frame, after the current document click has finished. The frame belongs to the field and is cancelled on unmount, so a deferred show cannot outlive the field.
The visual UI is unchanged, so there is no meaningful static screenshot to attach or circle. The defect is covered by a test that mounts the component in an isolated HTML document owned by a React root and verifies the first pointer click opens the list.
Verification
pnpm exec eslint packages/core/src/DateTimeInput/DateTimeInput.tsx packages/core/src/DateTimeInput/DateTimeInput.test.tsxpnpm -F @astryxdesign/core typecheckpnpm check:syncpnpm check:changesetspnpm check:repoThe complete DateTimeInput test file is otherwise clean in this environment (213 tests pass); one existing locale assertion expects ICU's Korean
오후 2:30, while this Node runtime formats the same value asPM 2:30.Closes #11763
Follow-up: #13120.
BaseTypeaheadstill defers a press-time show through a one-shotdocumentclick listener; that issue tracks moving it to this field-owned pending show.