[Bug] DateInput returns focus to the first opener when clicking a second input from the grid
Description
When keyboard focus is on a day inside the first DateInput's calendar, clicking a second DateInput closes the first calendar but restores focus to the first field's Open calendar button. The second calendar can open without its text input getting focus, so the following keystrokes do not reach that input.
The second input should keep the focus from the click and receive the typed date. Escape from the first calendar should still return focus to its opener.
Reproduction
Render two controlled DateInputs with the public Neutral theme and the en-GB locale. For example
import {useState} from 'react';
import {DateInput} from '@astryxdesign/core/DateInput';
function Dates() {
const [first, setFirst] = useState('2026-12-15');
const [second, setSecond] = useState(undefined);
return (
<main style={{display: 'flex', gap: 180, alignItems: 'start', margin: 80}}>
<DateInput label="First date" format="numeric" width={240}
presentation="popover" value={first} onChange={setFirst} />
<DateInput label="Second date" format="numeric" width={240}
presentation="popover" value={second} onChange={setSecond} />
</main>
);
}
- Tab to the first Open calendar button and press Enter. In 0.7.17, focus begins on Previous month.
- Tab twice to December 15, then press Right Arrow. Confirm December 16 in the first grid has focus.
- Click the second text input with a mouse. Type
16/12/2026.
The event trace records the trusted pointerdown on the second input while the first grid day has focus. Before the first popover reports its close, focus moves within the first widget. At pointerup and click, focus is on its Open calendar button. The second popover opens with focus still on the first button.
Opening by clicking the first text input and leaving focus there gives a useful control. In that case the second click does take focus and typing succeeds. PR #4974 covers that earlier text-field-open behavior. #11988 tracks where keyboard opening places focus.
Source review of public main found that DateInput's onHide already avoids refocusing the field when focus is moving elsewhere. Popover can restore the opener synchronously at close start, before that callback. A focused day, a pointer click on a second field, and an Escape control would cover the difference in a browser regression. DateInput source · Popover close-start source
Astryx Version
Public npm @astryxdesign/[email protected] and @astryxdesign/[email protected], React 19.2.0. Public main was reviewed in source only.
Environment
Chromium 156.0.8078.4 on Linux, 1440 × 900, mouse input, reduced motion.
Hi! I'd be interested in working on this issue.
I went through the reported focus-restoration behavior and think I can investigate the root cause, implement a fix, and add regression tests covering both pointer-based focus preservation and Escape behavior.
Would it be possible to assign this issue to me? I'd be happy to submit a PR following the repository's contributing guidelines.
🤖 (Posted by Cindy's agent.) Thanks for the precise reproduction and event trace, @duytbp. A fix is in progress in #13555: a popover, dialog or menu that closes while focus is moving to another control now leaves focus there, so the second DateInput keeps the focus from the click and gets the typed date. Escape from the calendar grid still returns focus to the "Open calendar" button.
@LekhNayak, thank you for offering. Since a fix is already in review, a review of #13555 would be very welcome, or you could pick another open bug that nobody has claimed yet.
🤖 (Posted by Cindy's agent.) Fixed by #13555, now merged: when a popover, dialog or menu closes while focus is moving from inside it to another control, focus now stays on that control. With a day focused in one DateInput's calendar, a press on a second DateInput keeps the focus from the press, and the typed date reaches it. Escape from the grid still returns focus to the "Open calendar" button. Thanks again for the precise trace, @duytbp! It ships in the next release.