[iOS] Fabric: Only add selection of textinput payload when event is selectionChange#51051
[iOS] Fabric: Only add selection of textinput payload when event is selectionChange#51051zhongwuzw wants to merge 4 commits into
Conversation
|
cc @cipolleschi is this something you can import/review/merge? |
cipolleschi
left a comment
There was a problem hiding this comment.
Code looks good to me.
I wonder how the types on JS get messed up like this.
To be fair, the selectionChange event doesn't have the text property either... and I don't know why the selectionChange event does not have the eventCount: number; that the textChanged has...
I'll import this and ask these questions to other people internally.
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
|
||
| static jsi::Value textInputMetricsPayload( | ||
| jsi::Runtime& runtime, | ||
| const std::string& name, |
There was a problem hiding this comment.
some internal feedback: can we instead have something like includeSelectionState as a boolean to avoid the string comparison?
…/consolidate_textinput_change
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
This pull request was successfully merged by @zhongwuzw in 3bfbaa8 When will my fix make it into a release? | How to file a pick request? |
|
@cipolleschi merged this pull request in 3bfbaa8. |
Summary: This change adds `selection` data to the `TextInput.onChange` event for both iOS and Android platforms. NOTE: `selection` only represents the cursor location when returned via `onChange` as this will not be invoked on a pure selection change without text change. We should also add this note to the documentation. ## Why On the web, text input elements provide `selectionStart` and `selectionEnd` properties that are always accessible during input events. React Native's `onChange` event previously included `selection` on iOS (Fabric), but this was removed in PR [react#51051](react#51051) to unify with Android (which never had it). This change restores and extends this capability to both platforms, better aligning React Native with web standards. This is also to support pollyfill added in `react-strict-dom`; react/react-strict-dom#435 ## What Changed 1. **iOS/macOS (C++)**: Enable selection in `onChange` event via `TextInputEventEmitter` 2. **Android (Kotlin)**: Added selection data to `ReactTextChangedEvent` Changelog: [General][Added] - TextInput onChange event now includes selection data (cursor location) on iOS and Android Reviewed By: cipolleschi, javache Differential Revision: D90123295
Summary: Pull Request resolved: #55044 This change adds `selection` data to the `TextInput.onChange` event for both iOS and Android platforms. NOTE: `selection` only represents the cursor location when returned via `onChange` as this will not be invoked on a pure selection change without text change. We should also add this note to the documentation. ## Why On the web, text input elements provide `selectionStart` and `selectionEnd` properties that are always accessible during input events. React Native's `onChange` event previously included `selection` on iOS (Fabric), but this was removed in PR [#51051](#51051) to unify with Android (which never had it). This change restores and extends this capability to both platforms, better aligning React Native with web standards. This is also to support pollyfill added in `react-strict-dom`; react/react-strict-dom#435 ## What Changed 1. **iOS/macOS (C++)**: Enable selection in `onChange` event via `TextInputEventEmitter` 2. **Android (Kotlin)**: Added selection data to `ReactTextChangedEvent` Changelog: [General][Added] - TextInput onChange event now includes selection data (cursor location) on iOS and Android Reviewed By: cipolleschi, javache Differential Revision: D90123295 fbshipit-source-id: 988ce4ce737e8b297313ade8bfaa2cbbfc9758cf
Summary:
Fixes #51020: TextInputChangeEventData does not contain selection (see here). Additionally, Android does not have selection either (see here) (iOS old arch also not contains it). We can consolidate these to prevent any misleading information.
Changelog:
[IOS] [FIXED] - Fabric: Only add selection of textinput payload when event is selectionChange
Test Plan:
TextInput
onChange's event should not containsselection.