Closed QichenZhu closed 1 month ago
TextInput with selectTextOnFocus set to true selects text within a setTimeout. Even if the input is no longer focused after the timeout, it still selects text and refocuses itself.
TextInput
selectTextOnFocus
true
setTimeout
Related issue: https://github.com/Expensify/App/issues/44245.
TextInput should only select text if it is still focused after the timeout.
Package version: 0.19.* Browser: Chrome 127.0.6533.72 Operating system: macOS 13.6.7
Item 19
Tab
Expected result: The highlighted item is focused and pressing Tab again highlights the next item..
Actual result: The text input is focused and pressing Tab again highlights Item 0.
Item 0
https://codesandbox.io/p/sandbox/gallant-sun-zw5675
A possible fix is to check if the text input is still focused in the setTimeout callback function below.
https://github.com/necolas/react-native-web/blob/54c14d64dabd175e8055e1dc92e9196c821f9b7d/packages/react-native-web/src/exports/TextInput/index.js#L292-L296
Is there an existing issue for this?
Describe the issue
TextInput
withselectTextOnFocus
set totrue
selects text within asetTimeout
. Even if the input is no longer focused after the timeout, it still selects text and refocuses itself.Related issue: https://github.com/Expensify/App/issues/44245.
Expected behavior
TextInput
should only select text if it is still focused after the timeout.Steps to reproduce
Package version: 0.19.* Browser: Chrome 127.0.6533.72 Operating system: macOS 13.6.7
Item 19
.Tab
key for at least 5 seconds.Item 19
. If it settles onItem 19
, return to step 3.Expected result: The highlighted item is focused and pressing
Tab
again highlights the next item..Actual result: The text input is focused and pressing
Tab
again highlightsItem 0
.Test case
https://codesandbox.io/p/sandbox/gallant-sun-zw5675
Additional comments
A possible fix is to check if the text input is still focused in the
setTimeout
callback function below.https://github.com/necolas/react-native-web/blob/54c14d64dabd175e8055e1dc92e9196c821f9b7d/packages/react-native-web/src/exports/TextInput/index.js#L292-L296