Open ilaloov opened 1 month ago
@ilaloov Is this happening on New architecture as well?
@shubhamguptadream11 Yes, both with new architecture enabled and disabled
:warning: | Newer Version of React Native is Available! |
---|---|
:information_source: | You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |
Hey @ilaloov, do you see this issue happening on both Android and iOS? I can see the issue happening on Android but it seems to be fine on iOS.
@coado I double-checked on iOS (emulator). It might be the emulator, but it triggers twice as well. However, the returned value (height) is constant, whereas on Android, it varies (20.39215660095215, 39.607845306396484).
@ilaloov This is how it works for me on iPhone 16 emulator. The onContentSizeChange
in outside TextInput
is printed twice initially, but when I open a modal with the inside TextInput
it prints only once.
https://github.com/user-attachments/assets/efb75619-a388-4e42-85be-9345f6096625
I think I found what causes this issue. The problem is that on Android the screen size in modal view state is updated asynchronous which leads to triggering onLayout in ReactEditText
multiple times. Setting the screen size before the layout happens similarly to how it is handled on iOS seems to fix it. I will try to open a PR shortly.
Description
When using a TextInput inside a Modal, the onContentSizeChange callback is triggered twice instead of once. Outside the Modal the event triggers correctly (only once).
Steps to reproduce
React Native Version
0.76.0
Affected Platforms
Runtime - Android, Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/ilaloov/textinput-issue
Screenshots and Videos
No response