Skip to content

[fix] Focus jumps between TextInputs#2163

Closed
maevic wants to merge 1 commit intonecolas:masterfrom
maevic:fix-selectonfocus
Closed

[fix] Focus jumps between TextInputs#2163
maevic wants to merge 1 commit intonecolas:masterfrom
maevic:fix-selectonfocus

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.

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

3 participants