Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure field is focused when selected #8566

Merged
merged 1 commit into from Jun 24, 2022
Merged

Ensure field is focused when selected #8566

merged 1 commit into from Jun 24, 2022

Conversation

elstgav
Copy link
Contributor

@elstgav elstgav commented Jun 24, 2022

As noted by MDN, calling element.select() doesn’t necessarily focus the element. As such, they recommend calling element.focus() too.

I believe the expectation when calling setFocus(name, { shouldSelect: true }) is that the field would be both selected and focused.

As noted by MDN, calling `element.select()` doesn’t necessarily focus the
element. As such, they recommend calling `element.focus()` too.

See https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select#notes
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b549486:

Sandbox Source
React Hook Form V7 (JS) Template Configuration
React Hook Form V7 (TS) Template Configuration

@bluebill1049
Copy link
Member

thanks for the PR.

@bluebill1049 bluebill1049 merged commit 6ec36a8 into react-hook-form:master Jun 24, 2022
@elstgav elstgav deleted the ensure-focus-when-select branch June 24, 2022 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants