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

[fix] Focus jumps between TextInputs #2163

Closed
wants to merge 1 commit into from

Conversation

maevic
Copy link

@maevic maevic commented Nov 8, 2021

Adding the property selectTextOnFocus to multiple TextInputs can cause the focus to jump between them indefinitely. This PR fixes the corresponding issue #2162.

@@ -243,7 +243,8 @@ const TextInput: React.AbstractComponent<
}
if (selectTextOnFocus) {
// Safari requires selection to occur in a setTimeout
setTimeout(() => {
clearTimeout(TextInput.focusTimeout);
TextInput.focusTimeout = setTimeout(() => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout should be managed as a ref or callback instead of this approach

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we used refs we'd only have access to this instance's timeout. But we need to clear a timeout created by another TextInput instance.

@necolas necolas added this to the 0.17.x milestone Feb 7, 2022
@necolas necolas closed this in d21c401 Feb 17, 2022
rnike pushed a commit to VeryBuy/react-native-web that referenced this pull request Sep 13, 2022
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.

2 participants