Skip to content

fix(focus return): a layer that closes while focus moves from inside it to another control leaves focus there - #13555

Merged
cixzhang merged 5 commits into
mainfrom
fix/date-input-second-field-keeps-focus
Nov 22, 2026
Merged

cixzhang merged 5 commits into
mainfrom
fix/date-input-second-field-keeps-focus

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Bug fix: a popover, dialog or menu that closes while focus moves from inside it to another control no longer pulls focus back to its opener. A move that starts outside the layer is not affected: there the focus already left the layer before the close.

Fixes #13518, reported by @duytbp with a reproduction and an event trace.

User impact

  • Who: keyboard users of DateInput, and anyone whose overlay closes as focus leaves it for another control.
  • Before: with a day focused in one DateInput's calendar, opened from its calendar button, a press on a second DateInput closed the first calendar and put focus back on the first field's "Open calendar" button. The second field's calendar opened, but typing went nowhere.
  • After: the second field keeps the focus the press gave it, and the typed date reaches it. Escape from the grid still returns focus to the "Open calendar" button.
  • Unchanged: a close with focus inside the layer or on nothing (Escape, a press on empty page space) still returns focus along the chain. Focus that is already outside stays where it is.

Cause

DateInput closes its calendar from the field's focusout, while focus is moving to the pressed field. During that event nothing is focused yet, so the shared focus return (utils/focusReturn.ts) read focus as stranded and focused the opener, which cancelled the browser's move.

Change

  • utils/focusReturn.ts: each open layer record notes the control outside the layer that focus is moving to, from a capture-phase blur (it reaches the document before the element's own blur and focusout listeners) to the next focusin; a target that cannot take focus clears the note after one task. isLayerFocusStranded treats that move as focus outside the layer, so the close leaves focus to that control. Every overlay that uses the shared return gets this.
  • Record: spec:AST-116 FR17 names that case: focus moving to a control outside the layer when the layer closes stays with that control. The verification row names the new tests.
  • Tests:
    • DateInputSecondFieldFocus.interaction.browser.spec.ts (Chromium): a focused grid day, a press on another field, focus and typed text in that field; and the Escape control.
    • layerFocusReturn.test.tsx: a close during a move, from a focusout or a native blur listener, never focuses the opener and leaves focus at the target (both fail on main); a close with no target still returns focus.
  • Changeset: [fix] patch.

Authority

  • spec:AST-116 FR17 (focus return acts only on stranded focus), amended here to name a close during a focus move. Specs to rule whether this is consistency or needs an owner decision.

Evidence

  • Red first (Chromium, real browser, core-dateinput--formats): "a press in another field from a focused grid day keeps focus in that field" fails on main (the second field is not focused) and passes here. The Escape control and the existing DateInputFocusLeave cases pass on both.
  • Units: utils, Popover, Dialog, Layer, DateInput, DateRangeInput, DateTimeInput, DropdownMenu, Selector, Drawer and MobileNav pass, 4,792 cases at this head. Chromium: the DateInput focus specs and the Popover and Dialog interaction specs pass, 59. The two jsdom cases count the opener's focus, so both fail on main (the opener takes focus once) and pass here, as the browser spec does.
  • tsc is clean; prettier is clean; check:knowledge is aligned.

Writing rubric results

  • R1 narration: none. FR17 states the rule in the present tense.
  • R2 research: none.
  • R3 evidence: the verification row names test files only.
  • R4 rejected alternatives: none.
  • R5 change references: none.
  • R6 open questions: none.
  • R7 project status: none.

Scope

Components: none directly (the shared layer focus return).

Owner and land path

  • Owner: Astryx maintainers, fix-loop lane 1.
  • Land path: draft; Specs, code review, device-evidence check, CI, merge.

@vercel

vercel Bot commented Nov 22, 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 22, 2026 9:43pm UTC

Request Review

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

astracat-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 22, 2026, 10:51 PM UTC

@cixzhang cixzhang added the lane:1 Astryx fix-loop lane 1 owns this label Nov 22, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 22, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 00d59e0

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 22, 2026
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 1b91ef8

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
DateInput · Storybook 209.8 kB (+99 B) · 19.0 kB CSS (0) 6,363 (0) ✗ · ✓ · ✓
lab/TransferListSelector 152.1 kB (+149 B) · 1.4 kB CSS (0) — — · — · —
Selector 121.7 kB (+140 B) · 19.7 kB CSS (0) — — · — · —
76 more components
Component Size LoC Visual · A11y · RTL
ChatComposerTokenElement 88.2 kB (+120 B) · 12.5 kB CSS (0) — — · — · —
ChatComposerInput 88.2 kB (+119 B) · 12.5 kB CSS (0) — — · — · —
ComplexSelector 84.2 kB (+117 B) · 13.3 kB CSS (0) — — · — · —
AlertDialog 134.6 kB (+115 B) · 16.3 kB CSS (0) — — · — · —
Drawer 58.5 kB (+115 B) · 8.7 kB CSS (0) — — · — · —
MultiSelector 109.9 kB (+113 B) · 18.9 kB CSS (0) — — · — · —
ChatComposer 91.1 kB (+111 B) · 13.5 kB CSS (0) — — · — · —
TopNavMegaMenu 82.3 kB (+110 B) · 13.1 kB CSS (0) — — · — · —
BreadcrumbItem 103.1 kB (+107 B) · 14.0 kB CSS (0) — — · — · —
PowerSearch 320.6 kB (+107 B) · 27.3 kB CSS (0) — — · — · —
Typeahead 95.3 kB (+107 B) · 14.4 kB CSS (0) — — · — · —
DropdownMenu 133.3 kB (+106 B) · 19.8 kB CSS (0) — — · — · —
Pagination 154.9 kB (+106 B) · 20.1 kB CSS (0) — — · — · —
MoreMenu 133.6 kB (+105 B) · 19.8 kB CSS (0) — — · — · —
Tokenizer 113.2 kB (+105 B) · 21.9 kB CSS (0) — — · — · —
Popover 105.8 kB (+104 B) · 15.5 kB CSS (0) — — · — · —
lab/CommentComposer 187.1 kB (+104 B) · 1.9 kB CSS (0) — — · — · —
TabMenu 84.9 kB (+100 B) · 12.3 kB CSS (0) — — · — · —
DateRangeInput 106.8 kB (+99 B) · 14.2 kB CSS (0) — — · — · —
SideNavHeading 88.7 kB (+99 B) · 12.5 kB CSS (0) — — · — · —
lab/Comments 390.7 kB (+99 B) · 2.5 kB CSS (0) — — · — · —
CommandPalette 84.1 kB (+98 B) · 13.5 kB CSS (0) — — · — · —
ContextMenuItem 39.2 kB (+98 B) · 7.3 kB CSS (0) — — · — · —
SideNavItem 83.0 kB (+98 B) · 12.3 kB CSS (0) — — · — · —
lab/ChatReactionBar 130.5 kB (+97 B) · 1.1 kB CSS (0) — — · — · —
TopNavMenu 87.9 kB (+96 B) · 12.4 kB CSS (0) — — · — · —
TopNavHeading 88.4 kB (+95 B) · 12.4 kB CSS (0) — — · — · —
lab/CommentThread 383.8 kB (+95 B) · 2.4 kB CSS (0) — — · — · —
DateTimeInput 234.1 kB (+94 B) · 20.7 kB CSS (0) — — · — · —
BaseTypeahead 84.4 kB (+93 B) · 12.1 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 317.0 kB (+93 B) · 454 B CSS (0) — — · — · —
Dialog 28.9 kB (+90 B) · 7.3 kB CSS (0) — — · — · —
lab/MediaCaptionsButton 229.5 kB (+90 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaPlaybackRate 229.5 kB (+90 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaPlayButton 229.5 kB (+90 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaSeekButton 229.5 kB (+90 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaTime 229.5 kB (+90 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaTimeSlider 229.5 kB (+90 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaVolume 229.5 kB (+90 B) · 1.5 kB CSS (0) — — · — · —
lab/VideoPlayer 236.8 kB (+90 B) · 2.1 kB CSS (0) — — · — · —
lab/MediaFullscreenButton 229.5 kB (+89 B) · 1.5 kB CSS (0) — — · — · —
lab/AudioPlayer 239.2 kB (+87 B) · 1.8 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 129.3 kB (+87 B) · 773 B CSS (0) — — · — · —
lab/Schedule 119.2 kB (+3 B) · 3.9 kB CSS (0) — — · — · —
TableHeaderCell 107.8 kB (+2 B) · 20.0 kB CSS (0) — — · — · —
Markdown 210.8 kB (+1 B) · 23.5 kB CSS (0) — — · — · —
TableSelectionToolbar 78.4 kB (+1 B) · 14.6 kB CSS (0) — — · — · —
ButtonGroup 44.9 kB (0) · 3.7 kB CSS (0) — — · — · —
ChatLayout 91.6 kB (0) · 11.7 kB CSS (0) — — · — · —
DropdownMenuItem 28.7 kB (0) · 7.1 kB CSS (0) — — · — · —
DropdownMenuSubMenu 80.9 kB (0) · 11.0 kB CSS (0) — — · — · —
LayoutPanel 22.4 kB (0) · 5.1 kB CSS (0) — — · — · —
Lightbox 151.6 kB (0) · 12.3 kB CSS (0) — — · — · —
NavHeadingMenu 19.1 kB (0) · 3.5 kB CSS (0) — — · — · —
TimeInput 182.2 kB (0) · 17.9 kB CSS (0) — — · — · —
TreeList 47.5 kB (0) · 6.0 kB CSS (0) — — · — · —
lab/CommentPin 61.8 kB (0) · 1.2 kB CSS (0) — — · — · —
lab/TabBar 84.7 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/TabBarItem 3.9 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/TourStep 97.3 kB (0) · 691 B CSS (0) — — · — · —
BottomSheetSwitcher 19.6 kB (−1 B) · 3.4 kB CSS (0) — — · — · —
Collapsible 30.1 kB (−1 B) · 4.5 kB CSS (0) — — · — · —
ContextMenu 106.7 kB (−1 B) · 19.6 kB CSS (0) — — · — · —
DropdownMenuRadioItem 29.6 kB (−1 B) · 7.6 kB CSS (0) — — · — · —
TabList 48.5 kB (−1 B) · 6.8 kB CSS (0) — — · — · —
Toolbar 48.4 kB (−1 B) · 8.6 kB CSS (0) — — · — · —
lab/NavigationScreen 86.6 kB (−1 B) · 1.5 kB CSS (0) — — · — · —
lab/NavigationStack 86.6 kB (−1 B) · 1.5 kB CSS (0) — — · — · —
AvatarGroup 49.8 kB (−2 B) · 6.1 kB CSS (0) — — · — · —
DropdownMenuCheckboxItem 29.6 kB (−2 B) · 7.6 kB CSS (0) — — · — · —
SideNav 116.3 kB (−2 B) · 12.6 kB CSS (0) — — · — · —
TableCell 107.9 kB (−2 B) · 20.2 kB CSS (0) — — · — · —
BottomSheet 76.9 kB (−3 B) · 7.8 kB CSS (0) — — · — · —
SegmentedControl 103.7 kB (−5 B) · 7.2 kB CSS (0) — — · — · —
Table 126.1 kB (−5 B) · 21.2 kB CSS (0) — — · — · —
AppShell 92.2 kB (−6 B) · 14.9 kB CSS (0) — — · — · —
Visual changes: 6 snapshots in 1 component

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

Component · story Before After Diff
DateInput · Open Calendar Audit (probe, dark) · inheritance unknown: not found in the 8 newest reports of other pull requests before frame after frame diff frame
DateInput · Open Calendar Audit (probe, light) · inheritance unknown: not found in the 8 newest reports of other pull requests before frame after frame diff frame
DateInput · Cleared Calendar Selection (neutral, light) · inheritance unknown: not found in the 8 newest reports of other pull requests before frame after frame diff frame
DateInput · Open Calendar Audit (neutral, light) · inheritance unknown: not found in the 8 newest reports of other pull requests before frame after frame diff frame
DateInput · Cleared Calendar Selection (neutral, dark) · inheritance unknown: not found in the 8 newest reports of other pull requests before frame after frame diff frame
DateInput · Open Calendar Audit (neutral, dark) · inheritance unknown: not found in the 8 newest reports of other pull requests before frame after frame diff frame

Inheritance checked against the 8 newest reports of other pull requests.

Package size: @astryxdesign/core 8.00 MB packed (+628 B); no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


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 fix works for the reported DateInput case, but the changeset and the amended FR17 claim more than the code covers.

  • A layer that closes from a native blur listener while focus moves to another control still sends focus back to its opener, because the record notes the move on focusout (packages/core/src/utils/focusReturn.ts:497) and browsers fire blur first; listen for blur in the capture phase there (it reaches the document before the element's own blur and focusout listeners, with the same relatedTarget) and add a unit case that closes from a native blur listener, or narrow the changeset, FR17 and the code comment to closes that run from a focusout (React onBlur) handler.

In Chromium, a press on the second DateInput now keeps focus and the typed text in that field, and Escape and a press on empty space still return focus to the calendar button. The inline comments add two non-blocking points: the browser spec's toHaveValue(/1/) already matches the field's prefilled "Mar 21, 2026", and two new source comments can be shorter and more exact.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Changeset: an overlay that closes while focus moves to another control no longer pulls focus back to its opener. False as written: true for a close from a focusout handler, false for a close from a native blur listener (checked in Chromium).
  • Changeset: from a focused calendar day, a press on a second DateInput keeps focus there and typing reaches it. Verified in Chromium; on the base, focus went to the first field's calendar button and the typed key was lost.
  • Changeset: Escape still returns focus to the opener. Verified in Chromium.
  • Changeset: a patch release of core. Verified.
  • Description, before and after: on the base, focus went to the first field's calendar button and typing was lost; at the head, the second field keeps focus and takes the typed text. Verified in Chromium.
  • Description, unchanged behavior: Escape and a press on empty page space still return focus, and focus that already left stays. Verified in Chromium and by the existing unit case.
  • Description, cause: DateInput closes from the field's focusout while focus is on the body. Verified (DateInput.tsx:890-905; Chromium reports the body during focusout).
  • Description, change: the record notes the outside control from focusout to the next focusin, clears it after one task, and the stranded test treats it as focus outside. Verified (focusReturn.ts:470-488, :719-726).
  • Description: every overlay on the shared return gets this. Verified (the shared focus trap's users and Dialog).
  • Description: FR17 names the case and the verification row names the new tests. Verified (spec.md:182-184, :369).
  • Description: the browser test fails on main and passes here. Verified with an equivalent Chromium run of its steps.
  • Description: the two unit cases are not red on main. Verified: they pass on the base.
  • Description: the listed unit suites pass. Verified with a larger set: 6,209 of 6,209.
  • Description: types, formatting and the knowledge check are clean. Verified.
  • File .changeset/close-keeps-focus-moving-elsewhere.md: the blocking finding (claim scope).
  • File docs/specs/AST-116-popover-anchoring/spec.md: clear, apart from the same scope point in FR17's parenthetical.
  • File packages/core/src/DateInput/__tests__/DateInputSecondFieldFocus.interaction.browser.spec.ts: non-blocking (the typed-text check cannot fail; the header says four fields, the story has five).
  • File packages/core/src/utils/focusReturn.ts: the blocking finding at line 497; non-blocking comment wording at lines 466-469 and 481.
  • File packages/core/src/utils/layerFocusReturn.test.tsx: clear.

Automated review (maintainer link)

Comment thread packages/core/src/utils/focusReturn.ts Resolved
Comment thread packages/core/src/utils/focusReturn.ts Resolved
Comment thread packages/core/src/utils/focusReturn.ts Resolved
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 4c15d8d

@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: CI has not run on this head yet.

The capture-phase blur note closes the earlier gap: a layer that closes from a native blur listener during a focus move now leaves focus on the outside control, so the release note, the spec text and the code comment match the code. Two non-blocking points are inline: the new native-blur unit case passes even without the fix, and the browser spec header miscounts the story's fields.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Changeset: an overlay that closes while focus moves to another control no longer pulls focus back to its opener. Verified for closes from a focusout handler and from a native blur listener (Chromium probe of focusReturn.ts; :466-505, :720-727).
  • Changeset: from a focused calendar day, a press on a second DateInput keeps focus in that field and typing reaches it. Verified in Chromium (the typed key lands in the second field; on the base, focus goes to the first field's calendar button).
  • Changeset: Escape still returns focus to the opener. Verified in Chromium.
  • Changeset: a patch release of core. Verified.
  • Description, before and after for keyboard users of DateInput. Verified in Chromium.
  • Description, unchanged: Escape and a press on empty space still return focus, and focus that already left stays. Verified (Chromium Escape; the no-target probe and unit cases).
  • Description, cause: DateInput closes its calendar from the field's focusout while nothing is focused. Verified (DateInput.tsx:890-905; the page reports the body during the move).
  • Description, change: the record notes the outside target from a capture-phase blur to the next focusin, clears it after one task, and the stranded check treats the move as focus outside. Verified (focusReturn.ts:466-505, :720-727).
  • Description: every overlay on the shared return gets this. Verified (the shared focus trap and Dialog).
  • Description: the spec names the case and its verification row names the new tests. Verified (spec.md:182-184, :369).
  • Description: the browser spec covers the press from a grid day and the Escape control. Verified (DateInputSecondFieldFocus.interaction.browser.spec.ts:70-104).
  • Description: the unit cases cover focusout, native blur and no-target closes. Verified that they exist and pass; the native blur case cannot fail (non-blocking).
  • Description: the browser test fails on main and passes here. Verified (Chromium).
  • Description: the unit cases are not red on main. Verified (they pass on the base).
  • Description: the listed unit suites pass. Verified with a larger set (291 test files).
  • Description: the DateInput focus specs and the Popover and Dialog interaction specs pass in Chromium, 59. Verified (59 passed).
  • Description: types, formatting and the knowledge check are clean. Verified.
  • File .changeset/close-keeps-focus-moving-elsewhere.md: clear.
  • File docs/specs/AST-116-popover-anchoring/spec.md: clear.
  • File packages/core/src/DateInput/__tests__/DateInputSecondFieldFocus.interaction.browser.spec.ts: non-blocking (the header counts four fields; the story has five).
  • File packages/core/src/utils/focusReturn.ts: clear.
  • File packages/core/src/utils/layerFocusReturn.test.tsx: non-blocking (the native blur case passes without the fix).

Automated review (maintainer link)


/**
* @file DateInputSecondFieldFocus.interaction.browser.spec.ts
* @input Storybook story core-dateinput--formats (four DateInput fields)

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.

Non-blocking (header). core-dateinput--formats renders five DateInput fields, not four.

 * @input Storybook story core-dateinput--formats (five DateInput fields)

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec a468279

@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: CI has not run on this head yet.

Merging main changed none of this pull request's files. A layer that closes from a focusout or a native blur listener during a focus move leaves focus on the outside control, and the release note and the amended spec text match the code. Two non-blocking points stay open in the existing inline threads: the native-blur unit case passes even without the fix, and the browser spec header says the story has four fields where it renders five.

Claims and files checked

Review mode: carry-forward; reason: none

  • The run-based checks below (Chromium, unit suites, types, formatting) were made on this same patch before the main merge, which changes none of its files.
  • Changeset: an overlay that closes while focus moves to another control no longer pulls focus back to its opener. Verified for closes from a focusout handler and from a native blur listener (Chromium probe of focusReturn.ts; :466-505, :720-727).
  • Changeset: from a focused calendar day, a press on a second DateInput keeps focus in that field and typing reaches it. Verified in Chromium (the typed key lands in the second field; on the base, focus goes to the first field's calendar button).
  • Changeset: Escape still returns focus to the opener. Verified in Chromium.
  • Changeset: a patch release of core. Verified.
  • Description, before and after for keyboard users of DateInput. Verified in Chromium.
  • Description, unchanged: Escape and a press on empty space still return focus, and focus that already left stays. Verified (Chromium Escape; the no-target probe and unit cases).
  • Description, cause: DateInput closes its calendar from the field's focusout while nothing is focused. Verified (DateInput.tsx:890-905; the page reports the body during the move).
  • Description, change: the record notes the outside target from a capture-phase blur to the next focusin, clears it after one task, and the stranded check treats the move as focus outside. Verified (focusReturn.ts:466-505, :720-727).
  • Description: every overlay on the shared return gets this. Verified (the shared focus trap and Dialog).
  • Description: the spec names the case and its verification row names the new tests. Verified (spec.md:182-184, :369).
  • Description: the browser spec covers the press from a grid day and the Escape control. Verified (DateInputSecondFieldFocus.interaction.browser.spec.ts:70-104).
  • Description: the unit cases cover focusout, native blur and no-target closes. Verified that they exist and pass; the native blur case cannot fail (non-blocking).
  • Description: the browser test fails on main and passes here. Verified (Chromium).
  • Description: the unit cases are not red on main. Verified (they pass on the base).
  • Description: the listed unit suites pass. Verified with a larger set (291 test files).
  • Description: the DateInput focus specs and the Popover and Dialog interaction specs pass in Chromium, 59. Verified (59 passed).
  • Description: types, formatting and the knowledge check are clean. Verified.
  • File .changeset/close-keeps-focus-moving-elsewhere.md: clear.
  • File docs/specs/AST-116-popover-anchoring/spec.md: clear.
  • File packages/core/src/DateInput/__tests__/DateInputSecondFieldFocus.interaction.browser.spec.ts: non-blocking (the header counts four fields; the story has five).
  • File packages/core/src/utils/focusReturn.ts: clear.
  • File packages/core/src/utils/layerFocusReturn.test.tsx: non-blocking (the native blur case passes without the fix).

Automated review (maintainer link)

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

Changes requested.

  • Miss: the title and release note say any popover, dialog or menu that closes while focus moves to another control leaves focus there, but focusReturn.ts notes the move only when it starts inside the layer (line 477), so with the first DateInput's calendar open and focus in that field's own text, a press on the second field still sends focus back to the first field's calendar button in Chromium and the typed text is lost; either note every move to an outside element while the layer is open and add that case to the browser spec, or narrow the title, release note and the spec's new clause to a close while focus leaves the layer.

The reported case is fixed: from a focused calendar day, a press on the second field now keeps focus and the typed text there, and Escape still returns focus to the calendar button. Two non-blocking points stay open in their inline threads: the native blur unit case passes without the fix, and the browser spec header says four fields where the story renders five.

Claims and files checked

Review mode: same-head; reason: none

  • Release note, an overlay that closes while focus moves to another control no longer pulls focus back to its opener: false for a move that starts outside the layer. In Chromium at this head, focus returns to the first calendar button.
  • Release note, a press on a second DateInput from a focused calendar day keeps focus and typing in that field: verified in Chromium (fails on the base, passes here).
  • Release note, Escape still returns focus to the opener: verified in Chromium.
  • Release note, a patch release of core: verified.
  • Description, primary intent: the same broad claim as the release note, and false for the same case.
  • Description, before and after for keyboard users of DateInput: verified in Chromium.
  • Description, unchanged behavior (Escape and a press on empty space still return focus, and focus already outside stays): verified by the Escape run, the no-target unit case and the otherwise unchanged stranded check.
  • Description, cause (the field's blur handler closes the calendar while nothing is focused, and the shared return focuses the opener): verified by a focus-call trace on the base.
  • Description, change (the record notes the outside target from a capture-phase blur until the next focusin, clears it after one task, and the stranded check treats the move as outside): verified, for a blur that starts inside the layer only.
  • Description, every overlay on the shared return gets this: verified (the shared focus trap and Dialog).
  • Description, the spec names the case and its verification row names the new tests: verified.
  • Description, the browser spec covers the press from a calendar day and the Escape control: verified. It passes in CI's full Chromium interaction run at this head.
  • Description, the unit cases cover a close from focusout, from native blur and with no target: they exist and pass. The native blur case also passes without the fix (non-blocking).
  • Description, the browser test fails on main and passes here: verified in Chromium.
  • Description, the unit, browser, type, formatting and knowledge checks pass: CI's checks pass at this head.
  • Description, writing rubric: the new spec text is in the present tense, and the verification row names test files only. Verified.
  • File .changeset/close-keeps-focus-moving-elsewhere.md: blocking (claims more than the code covers).
  • File docs/specs/AST-116-popover-anchoring/spec.md: part of the blocking finding (the new clause's main text reads wider than its example and the code).
  • File packages/core/src/DateInput/__tests__/DateInputSecondFieldFocus.interaction.browser.spec.ts: non-blocking (the header counts four fields, but the story has five).
  • File packages/core/src/utils/focusReturn.ts: blocking (a move that starts outside the layer is not noted).
  • File packages/core/src/utils/layerFocusReturn.test.tsx: non-blocking (the native blur case passes without the fix).

Automated review (maintainer link)

Comment thread packages/core/src/utils/focusReturn.ts Resolved
@cixzhang cixzhang changed the title fix(focus return): a layer that closes while focus moves to another control leaves focus there fix(focus return): a layer that closes while focus moves from inside it to another control leaves focus there Nov 22, 2026
@cixzhang
cixzhang marked this pull request as draft November 22, 2026 21:32
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 1b91ef8

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

Changes requested.

  • The description's Evidence section says the two jsdom cases "are not red on main", but both new cases in layerFocusReturn.test.tsx now fail on main (the opener takes focus once) and pass here, as the Tests bullet says, so please correct that sentence and the "4,713/4,713" tally, which is 4,792 cases at this head.

The reported case is fixed: from a focused calendar day, a press on the second DateInput keeps focus and the typed text there, the new Chromium spec fails on main and passes here, and Escape still returns focus to the calendar button. The narrowed title and release note settle the earlier scope point. Two non-blocking points: FR17's new clause could say "moving from inside the layer to a control outside it" to match the code (inline comment), and the browser spec's header says four fields where the Formats story renders five.

Claims and files checked

Review mode: incremental; reason: none

  • Release note, an overlay that closes while focus moves from inside it to another control no longer pulls focus back to its opener: verified (the blur note and the stranded check, and Chromium).
  • Release note, a press on a second DateInput from a focused calendar day keeps focus and typing there: verified in Chromium (fails on main, passes here).
  • Release note, Escape still returns focus to the opener: verified in Chromium on main and here.
  • Release note, a patch release of core: verified.
  • Description, primary intent, the same rule for a move that starts inside the layer: verified.
  • Description, a move that starts outside the layer is not affected: verified (the note requires a blur from inside the layer; Chromium behaves as on main).
  • Description, fixes the linked issue: verified with the issue's steps in the Formats story.
  • Description, before and after for keyboard users of DateInput: verified in Chromium.
  • Description, unchanged behavior (Escape and a close with nothing focused still return focus; focus already outside stays): verified by the Escape run and the no-target unit case.
  • Description, cause (the field's focusout closes the calendar while nothing is focused, and the shared return focuses the opener): verified in the code and on main in Chromium.
  • Description, change (the note from a capture-phase blur until the next focusin, cleared after one task, honoured by the stranded check, for every overlay on the shared return): verified.
  • Description, the spec names the case and its verification row names the new tests: verified.
  • Description, the browser spec covers the press from a calendar day and the Escape control: verified.
  • Description, the two jsdom cases from focusout and from native blur never focus the opener and fail on main; the no-target case returns focus: verified (both fail on main, pass here).
  • Description, the browser spec fails on main and passes here, and the existing focus-leave cases pass on both: verified in Chromium.
  • Description, the named unit suites pass, 4,713 of 4,713: they pass; this head runs 4,792 cases in them.
  • Description, the DateInput focus specs and the Popover and Dialog interaction specs pass: verified (one frame-timing proof failed with two workers and passes on its own, on main and here).
  • Description, the jsdom cases are not red on main: false (both fail on main).
  • Description, type check, formatting and knowledge checks are clean: formatting and knowledge checks verified; the core build's type check passes.
  • Description, writing rubric: the new spec text is in the present tense and the verification row names test files only: verified.
  • File .changeset/close-keeps-focus-moving-elsewhere.md: clear.
  • File docs/specs/AST-116-popover-anchoring/spec.md: non-blocking (the new clause's main text reads wider than its parenthetical).
  • File packages/core/src/DateInput/__tests__/DateInputSecondFieldFocus.interaction.browser.spec.ts: non-blocking (the header counts four fields, the story has five).
  • File packages/core/src/utils/focusReturn.ts: clear.
  • File packages/core/src/utils/layerFocusReturn.test.tsx: clear; the description's account of it is the blocking finding.

Automated review (maintainer link)

Comment on lines +182 to +184
a caller moved in its own hide notification, and focus that is moving to a
control outside the layer when the layer closes (a close that runs while
focus leaves the layer for that control, such as a press on another field).

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.

Non-blocking (wording). The main text, "focus that is moving to a control outside the layer when the layer closes", also covers a press on another field made after focus went back from the calendar to the field's own text. In that case focus still returns to the opener, because focusReturn.ts notes only a blur from inside the layer. The parenthetical and the release note already limit the case. Say so in the main text too:

a caller moved in its own hide notification, and focus that is moving from
inside the layer to a control outside it when the layer closes (a close that
runs while focus leaves the layer for that control, such as a press on
another field).

@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. CI passed on this head.

The fix does what the release note says: a popover or menu that closes while focus moves from inside it to another control leaves focus on that control, and the new browser and unit cases fail on main and pass here. Two non-blocking points stay open in their inline threads: the record's new sentence could say "moving from inside the layer to a control outside it" to match the code, and the browser spec's header says four fields where the Formats story renders five.

Claims and files checked

Review mode: same-head; reason: none

  • Release note, an overlay that closes while focus moves from inside it to another control no longer pulls focus back to its opener: verified (the blur note and the stranded check, and the unit cases).
  • Release note, a press on a second DateInput from a focused calendar day keeps focus and typing there: verified in Chromium (fails on main, passes here).
  • Release note, Escape still returns focus to the opener: verified in Chromium on main and here.
  • Release note, a patch release of core: verified.
  • Description, primary intent, a move from inside the layer only, with a move that starts outside unaffected: verified (the note requires a blur from inside the layer).
  • Description, fixes the linked issue, reported with a reproduction and an event trace: verified.
  • Description, before and after for keyboard users of DateInput: verified in Chromium.
  • Description, unchanged behavior (Escape and a close with nothing focused still return focus; focus already outside stays): verified by the Escape case and the no-target unit case.
  • Description, cause (the field's focusout closes the calendar while nothing is focused, and the shared return focuses the opener): verified in the code.
  • Description, change (the note from a capture-phase blur until the next focusin, cleared after one task, honoured by the stranded check, for every overlay on the shared return): verified.
  • Description, the record names the case and its verification row names the new tests: verified.
  • Description, the browser spec covers the press from a calendar day and the Escape control: verified.
  • Description, the unit cases from focusout and from a native blur never focus the opener and fail on main; the no-target case returns focus: verified (rerun: both fail on main, pass here).
  • Description, the changeset is a patch fix: verified.
  • Description, the record amendment and its owner approval for this head: verified.
  • Description, the browser spec fails on main and passes here, and the existing focus-leave cases pass on both: verified in Chromium.
  • Description, the named unit suites pass, 4,792 cases: verified.
  • Description, the DateInput focus specs and the Popover and Dialog interaction specs pass in Chromium, 59: verified.
  • Description, the two unit cases fail on main and pass here, as the browser spec does: verified.
  • Description, type check, formatting and knowledge checks are clean: verified.
  • Description, writing rubric (present tense, the verification row names test files only, no narration, references or status): verified.
  • Description, scope names no component directly: verified (no public API change).
  • Description, owner and land path: a process plan, nothing in the code to check; the pull request has since left draft.
  • File .changeset/close-keeps-focus-moving-elsewhere.md: clear.
  • File docs/specs/AST-116-popover-anchoring/spec.md: non-blocking (the new sentence's main text reads wider than its parenthetical).
  • File packages/core/src/DateInput/__tests__/DateInputSecondFieldFocus.interaction.browser.spec.ts: non-blocking (the header counts four fields, the story has five).
  • File packages/core/src/utils/focusReturn.ts: clear.
  • File packages/core/src/utils/layerFocusReturn.test.tsx: clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 22, 2026 22:27
github-actions Bot added a commit that referenced this pull request Nov 22, 2026
@cixzhang
cixzhang merged commit b29bc4d into main Nov 22, 2026
163 checks passed
@github-actions
github-actions Bot deleted the fix/date-input-second-field-keeps-focus branch November 23, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — 1b91ef8e Deployed Nov 22, 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. lane:1 Astryx fix-loop lane 1 owns this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] DateInput returns focus to the first opener when clicking a second input from the grid

1 participant