Skip to content

Commit

Permalink
[fix] TextInput refocusing issue with selectTextOnFocus
Browse files Browse the repository at this point in the history
Check if the input is still focused before selecting text

Fix #2704
  • Loading branch information
QichenZhu authored and necolas committed Oct 15, 2024
1 parent 907aac9 commit e922224
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react-native-web/src/exports/TextInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ const TextInput: React.AbstractComponent<
clearTimeout(focusTimeout);
}
focusTimeout = setTimeout(() => {
if (hostNode != null) {
// Check if the input is still focused after the timeout
// (see #2704)
if (hostNode != null && document.activeElement === hostNode) {
hostNode.select();
}
}, 0);
Expand Down

0 comments on commit e922224

Please sign in to comment.