🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@nakambo
Copy link
Collaborator

@nakambo nakambo commented Apr 10, 2025

These two functions are used to properly handle onFocus\onBlur for TextInput implementations, specifically they are used to track the currently focused TextInput control and as such cause focusTextInput and blurTextInput to skip native focus\blur calls if the JS side thinks the control in question is already focused\blurred.

In other words, if someone wants to build a custom <TextInput> from the ground up, they can't expect focusTextInput, blurTextInput, and currentlyFocusedInput (the last one which is especially already used in a bunch of places in the framework) to work properly. This change exports the necessary focusInput and blurInput out of TextInput statics.

[These two functions](https://github.com/microsoft/react-native-macos/blob/9ea059c33143e6766582a1f682e4f144e00cc740/packages/react-native/Libraries/Components/TextInput/TextInputState.js#L60C1-L70C2) are used to [properly handle onFocus\onBlur for TextInput implementations](https://github.com/microsoft/react-native-macos/blob/9ea059c33143e6766582a1f682e4f144e00cc740/packages/react-native/Libraries/Components/TextInput/TextInput.js#L1623C1-L1635C5), specifically they are used to track the currently focused TextInput control and as such cause [focusTextInput](https://github.com/microsoft/react-native-macos/blob/9ea059c33143e6766582a1f682e4f144e00cc740/packages/react-native/Libraries/Components/TextInput/TextInputState.js#L106C1-L106C48) and [blurTextInput](https://github.com/microsoft/react-native-macos/blob/9ea059c33143e6766582a1f682e4f144e00cc740/packages/react-native/Libraries/Components/TextInput/TextInputState.js#L143C1-L143C69) to skip native focus\blur calls if the JS side thinks the control in question is already focused\blurred.

In other words, if someone wants to build a custom `<TextInput>` from the ground up, they can't expect `focusTextInput`,  `blurTextInput`, and `currentlyFocusedInput` (the last one which is especially already used in a bunch of places in the framework) to work properly. This change exports the necessary `focusInput` and `blurInput` out of [TextInput](https://github.com/microsoft/react-native-macos/blob/9ea059c33143e6766582a1f682e4f144e00cc740/packages/react-native/Libraries/Components/TextInput/TextInput.js#L2041C1-L2048C3) statics.
@nakambo nakambo requested a review from Saadnajmi April 10, 2025 17:41
@nakambo nakambo requested a review from a team as a code owner April 10, 2025 17:41
@nakambo nakambo enabled auto-merge (squash) April 10, 2025 20:57
@nakambo nakambo merged commit 91790e2 into main Apr 10, 2025
12 checks passed
@nakambo nakambo deleted the nakambo/export-ti-onfocus-onblur branch April 10, 2025 21:04
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