Repository navigation
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes
Summary
Calling
.focus()on the ref passed to the rootDateField/TimeFielddoes nothing: the ref points at a plain wrapper<div>with notabindex. Form validation already focuses the first segment on submit (viauseDateField's internal focus manager), so users expect the root ref to behave the same.Expected:
ref.current.focus()moves focus to the first segment. Actual: focus is not moved (and is lost after a failed required-field submit if the app tries to refocus via the ref).Fix: a small
useFocusFirstSegmenthelper exposes the root div throughuseImperativeHandlewithfocus()delegating tocreateFocusManager(fieldRef).focusFirst(). The ref type staysHTMLDivElement.issue was especially visible when working with react-hook-form; the library gives you a ref that will be later used to focus invalid fields. Passing the ref to textfield does focus the field upon submit, but it's not the case for date-field, and I think it would make sense that refs passed to
*Fieldcomponents resolve to the right focusable child consistently.Wdyt?
Not covered:
DatePicker/DateRangePickerroot refs have the same gap.📝 Test Instructions
yarn jest packages/react-aria-components/test/DateField.test.js packages/react-aria-components/test/TimeField.test.js packages/react-aria-components/test/DatePicker.test.js→ 3 suites, 69 tests pass.DateField.test.js(focuses the first segment when focus() is called on the root ref). I did not run it against the unfixed code to confirm it fails.tsc --noEmit: no errors inreact-aria-components.TimeFieldhas no dedicated test for the new behavior.Release impact
✅ PR Checklist
🧢 Your Project
Qonto
AI disclosure: written with Claude Code assistance.
🤖 Generated with Claude Code