-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: dispatch ContentSizeChange event on Fabric on iOS #35816
Closed
WoLewicki
wants to merge
2
commits into
facebook:main
from
WoLewicki:@wolewicki/fix-fabric-text-input-event
Closed
fix: dispatch ContentSizeChange event on Fabric on iOS #35816
WoLewicki
wants to merge
2
commits into
facebook:main
from
WoLewicki:@wolewicki/fix-fabric-text-input-event
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Jan 12, 2023
Base commit: 8befb74 |
Hey @WoLewicki, thank you for the PR! TextInput can listen to size changes inside updateLayoutMetrics, I think that is better place for it. |
@sammy-SC has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Thanks @WoLewicki, this has been merged. |
OlimpiaZurek
pushed a commit
to OlimpiaZurek/react-native
that referenced
this pull request
May 22, 2023
Summary: On Fabric, `onContentSizeChange` of `TextInput` component was never fired on `iOS`, since the logic dispatching it was implemented in `RCTBaseTextInputShadowView` on Paper: https://github.com/facebook/react-native/blob/0f8dc067ac079f7b14696cfcafa37e3ec19a0409/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m#L105. This class is not used on Fabric, therefore the event was never dispatched. On Paper, it was dispatched in `dirtyLayout` method, so I added dispatching of this event based on the change of content size in `layoutSubviews` method, since this method seems the closest one on Fabric. I am not sure if it is the best place for it though. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS] [ADDED] - dispatch `onContentSizeChange` event on Fabric. Pull Request resolved: facebook#35816 Test Plan: Try to use `onContentSizeChange` callback in `TextInput` component: ```tsx import React from 'react'; import {TextInput, SafeAreaView} from 'react-native'; const App = () => { return ( <SafeAreaView style={{flex: 1, backgroundColor: 'red'}}> <TextInput multiline={true} placeholder="type here" onContentSizeChange={e => console.log(e)} /> </SafeAreaView> ); }; export default App; ``` Reviewed By: christophpurrer Differential Revision: D42499974 Pulled By: sammy-SC fbshipit-source-id: 3e010ff096cf91cb3e7b87ed2753e9d0e7be9650
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Merged
This PR has been merged.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
On Fabric,
onContentSizeChange
ofTextInput
component was never fired oniOS
, since the logic dispatching it was implemented inRCTBaseTextInputShadowView
on Paper:react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m
Line 105 in 0f8dc06
dirtyLayout
method, so I added dispatching of this event based on the change of content size inlayoutSubviews
method, since this method seems the closest one on Fabric. I am not sure if it is the best place for it though.Changelog
[IOS] [ADDED] - dispatch
onContentSizeChange
event on Fabric.Test Plan
Try to use
onContentSizeChange
callback inTextInput
component: