Skip to content

Commit

Permalink
Fixed the height result of onContentSizeChange callback on iOS (#41803)
Browse files Browse the repository at this point in the history
Summary:
The height returned by TextInput's 'onContentSizeChange' callback method is incorrect

Because, the borderwidth and horizontal padding are not subtracted from the content width used to calculate the height of the text.

I have seen many people in the same situation in many issues. When I solved, some people suggested I submit a PR.

More information can be found here [https://github.com/facebook/react-native/issues/35234](https://github.com/facebook/react-native/issues/35234#issuecomment-1831141903)

## Changelog:

[IOS] [FIXED]  - the wrong height result of onContentSizeChange callback

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #41803

Test Plan: CI Green

Reviewed By: NickGerleman

Differential Revision: D51891909

Pulled By: dmytrorykun

fbshipit-source-id: fa297155ebdfc933cf0ea6bcdab37d7410809e8c
  • Loading branch information
zyestin authored and facebook-github-bot committed Dec 13, 2023
1 parent 70a757f commit 5217cc9
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ - (void)invalidateContentSize
return;
}

CGSize maximumSize = self.layoutMetrics.frame.size;
CGSize maximumSize = self.layoutMetrics.contentFrame.size;

if (_maximumNumberOfLines == 1) {
maximumSize.width = CGFLOAT_MAX;
Expand Down

0 comments on commit 5217cc9

Please sign in to comment.