-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: autoGrow prop on mobile is handled by native platform #59078
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: autoGrow prop on mobile is handled by native platform #59078
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
All contributors have signed the CLA ✍️ ✅ |
Hi @Nodonisko just wanna confirm if this PR will fix this issue #19961, wont it? |
I have read the CLA Document and I hereby sign the CLA |
Yes @Nodonisko is from margelo and took the task over from me 😊 |
@aimane-chnaif, because you're already assigned as C+ in this issue #19961, do you want to review this issue or me? |
After some testing it looks that iOS is really fixed but now Android seems to glitch in very similar way. I will continue my investigation. |
@hoangzinh seems like Aimane is ooo so please take it over |
🚧 @mountiny has triggered a test app build. You can view the workflow run here. |
Ahoj Daniel 👋 welcome to the team 🙇 Great job! let us know when the android part is ready too but I think @hoangzinh could already test and review the ios fix |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪
|
@Nodonisko can you help to merge the latest main into this branch? |
@Nodonisko regarding testing steps, please follow this guidlines In our case, it should be something like this:
|
@hoangzinh Sorry I will update testing guide, but probably hold on with testing for now because I discovered issue on Android that needs to be fixed first #19961 (comment) |
b21efa7
to
834c1d6
Compare
5e51ece
to
168e73f
Compare
@hoangzinh So I found simple hotfix in the end. 168e73f Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-04-16.at.10.46.50.mp4 |
@@ -80,6 +81,10 @@ function BaseTextInput( | |||
}: BaseTextInputProps, | |||
ref: ForwardedRef<BaseTextInputRef>, | |||
) { | |||
// For iOS, we don't need to measure the text input because it already has auto grow behavior | |||
// See TextInputMeasurement.ios.tsx for more details | |||
const isExternalAutoGrowMeasurement = Platform.OS !== 'ios' && autoGrow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isExternalAutoGrowMeasurement = Platform.OS !== 'ios' && autoGrow; | |
const isExternalAutoGrowMeasurement = getPlatform() !== CONST.PLATFORM.IOS && autoGrow; |
@@ -360,8 +369,8 @@ function BaseTextInput( | |||
placeholderTextColor={placeholderTextColor ?? theme.placeholderText} | |||
underlineColorAndroid="transparent" | |||
style={[ | |||
styles.flex1, | |||
styles.w100, | |||
!autoGrow && styles.flex1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why do we need to that this condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea sure, so previous solution (still present for Android) measured size of Text
component and set same width
to TextInput
so width was specified with some absolute value.
Now on iOS we must not have any width specified or native auto grow won't work. So we don't want to apply anything that will set width manually like flex1
or width100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Nodonisko
I would not worry about issues that are only in dev with the hardware keyboard for this pr but lets fix it without a workaround so maybe the new masked input in a next pr? |
@mountiny should @Nodonisko revert this workaround, or is it okay for now? |
Sorry if I was not clear. We can use it for now, but we should not drop the ball and still try to pursue more complex but better fix (and removing the workaround then) |
I see, I will try to complete review checklist tomorrow |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-04-19.at.13.13.00.android.movAndroid: mWeb ChromeScreen.Recording.2025-04-19.at.13.15.28.chrome.android.moviOS: NativeScreen.Recording.2025-04-19.at.15.15.03.moviOS: mWeb SafariScreen.Recording.2025-04-19.at.13.16.24.ios.safari.movMacOS: Chrome / SafariScreen.Recording.2025-04-19.at.13.00.16.web.movMacOS: DesktopScreen.Recording.2025-04-19.at.13.06.30.desktop.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for your patience and congrats @Nodonisko for one of your first prs!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.31-0 🚀
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.1.31-3 🚀
|
This PR seems to be causing this deploy blocker: #60765 |
@@ -273,6 +279,10 @@ function BaseTextInput( | |||
|
|||
// Height fix is needed only for Text single line inputs | |||
const shouldApplyHeight = !isMultiline && !isMarkdownEnabled; | |||
|
|||
// Fix iOS cursor jumping when entering first character using HW keyboard https://github.com/Expensify/App/pull/59078#issuecomment-2802834037 | |||
const selection = inputProps.selection?.end === 0 && inputProps.selection?.start === 0 ? undefined : inputProps.selection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change caused a bug. Details in #60640
Explanation of Change
This PR is based on work from @hannojg in #50238 and it's partially removing complicated
autoGrow
using layout events fromText
to update dimension ofTextInput
. This is not necessary on native platforms because they can auto grow by default.Sadly on Android there is bug in RN that is causing component to be jumpy if I remove this autoGrow features that are adding some width buffer to Android component. For that reason I moved most of measuring logic into new component that is used only for Android + Web platforms so even more code is now reused across web and native.
Fixed Issues
$ #19961
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
adndroid-text-input.webm
Android: mWeb Chrome
android-web.webm
iOS: Native
ios-text-input.mp4
iOS: mWeb Safari
ios-safari.mp4
MacOS: Chrome / Safari
web-chrome.mov
MacOS: Desktop
mac-desktop.mov