mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-08-15 18:45:06 +00:00
[fix] Avoid edge case where focus jumps between TextInputs
Close #2163 Fix #2162
This commit is contained in:
committed by
Nicolas Gallagher
parent
438b7b7281
commit
d21c401620
@@ -83,6 +83,8 @@ function isEventComposing(nativeEvent) {
|
||||
return nativeEvent.isComposing || nativeEvent.keyCode === 229;
|
||||
}
|
||||
|
||||
let focusTimeout: ?TimeoutID = null;
|
||||
|
||||
const TextInput: React.AbstractComponent<
|
||||
TextInputProps,
|
||||
HTMLElement & PlatformMethods
|
||||
@@ -243,8 +245,13 @@ const TextInput: React.AbstractComponent<
|
||||
}
|
||||
if (selectTextOnFocus) {
|
||||
// Safari requires selection to occur in a setTimeout
|
||||
setTimeout(() => {
|
||||
hostNode.select();
|
||||
if (focusTimeout != null) {
|
||||
clearTimeout(focusTimeout);
|
||||
}
|
||||
focusTimeout = setTimeout(() => {
|
||||
if (hostNode != null) {
|
||||
hostNode.select();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user