Skip to content
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

TextInput numberOfLines/maxNumberOfLines workaround (manually calculating maxHeight of TextInput #31483

Merged

Conversation

chrispader
Copy link
Contributor

@chrispader chrispader commented Nov 17, 2023

@Szymon20000 @roryabraham

Details

Temporary workaround for numberOfLines/maxNumberOfLines props on TextInput component. This workaround uses maxHeight and lineHeight styles to simulate the effect of the missing props, until the upstream RN RFC has been approved and the PR was merged.

https://expensify.slack.com/archives/C035J5C9FAP/p1700157933350519?thread_ts=1699609652.957299&cid=C035J5C9FAP

Fixed Issues

$
PROPOSAL:

Tests

  1. Go to a report/chat
  2. Press enter a couple of times in the composer
  3. Make sure the composer doesn't grow to more than 6 lines
  4. Go into full-size mode
  5. Make sure the composer extends to ~50% of the screen
  6. Exit full-size mode
  7. Clean input
  8. Make sure the composer shrinks again
  • Verify that no errors appear in the JS console

Offline tests

Same as in Tests.

QA Steps

  1. Check the same tests in release build
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.webm

Screenshot_20231117_164836

Android: mWeb Chrome
iOS: Native
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2023-11-17.at.16.45.00.mp4

Simulator Screenshot - iPhone 15 Pro - 2023-11-17 at 16 46 23

iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

Screen recordings added for iOS and Android

@chrispader chrispader marked this pull request as ready for review November 17, 2023 15:49
@chrispader chrispader requested a review from a team as a code owner November 17, 2023 15:49
@melvin-bot melvin-bot bot requested review from danieldoglas and removed request for a team November 17, 2023 15:50
Copy link

melvin-bot bot commented Nov 17, 2023

@danieldoglas 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]

@chrispader
Copy link
Contributor Author

Ready for review! 👍 @roryabraham @Szymon20000

@chrispader chrispader changed the title [WIP] numberOfLines/maxNumberOfLines workaround TextInput numberOfLines/maxNumberOfLines workaround (manually calculating maxHeight of TextInput Nov 17, 2023
@chrispader
Copy link
Contributor Author

We should probably prioritise this PR since it massively reduces Android build time, because once we remove this patch we no longer need to compile Android RN from source. :)

cc @roryabraham @AndrewGable

@danieldoglas
Copy link
Contributor

@situchan will review this PR as a C+ so we can move faster!

@chrispader
Copy link
Contributor Author

@situchan do you have some time to review this soon? :) Android build speed gainzz would be awesome to have haha

@situchan
Copy link
Contributor

reviewing today

@situchan
Copy link
Contributor

Installation time is now 9 min for me 👍

src/styles/StyleUtils.ts Outdated Show resolved Hide resolved
@situchan
Copy link
Contributor

BUG1: [iOS] last line is not removed after removing all text on that line

ios.bug.mov

@chrispader
Copy link
Contributor Author

@mountiny can we merge this now that iOS is building? Getting conflicts with main and i don't think we're holding on anything anymore? :)

@situchan
Copy link
Contributor

@mountiny Let's do that! I couldn't still be able to install above build on my iPhone but should not be blocker.
I will verify once hit staging.

@mountiny
Copy link
Contributor

@AndrewGable @danieldoglas can one of you approve and merge since you have been involved in this PR?

danieldoglas
danieldoglas previously approved these changes Jan 25, 2024
@danieldoglas
Copy link
Contributor

K, another conflict on this. I'm online for the next 3 hours, so please ping me if you solve the conflicts in that time and I'll merge it.

@chrispader
Copy link
Contributor Author

K, another conflict on this. I'm online for the next 3 hours, so please ping me if you solve the conflicts in that time and I'll merge it.

resolved! @danieldoglas

@danieldoglas
Copy link
Contributor

Waiting for the checks, then will merge.

@@ -1967,7 +1967,7 @@ SPEC CHECKSUMS:
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2
VisionCamera: 7d13aae043ffb38b224a0f725d1e23ca9c190fe7
Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047
Yoga: 13c8ef87792450193e117976337b8527b49e8c03
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: this change is irrelevant to this PR

Copy link

melvin-bot bot commented Jan 25, 2024

🎯 @situchan, thanks for reviewing and testing this PR! 🎉

An E/App issue has been created to issue payment here: #35167.

@AndrewGable AndrewGable merged commit c6fe2f0 into Expensify:main Jan 25, 2024
20 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@situchan
Copy link
Contributor

@chrispader can you please check this urgently?

On main, I am seeing multiple lines in LHN.

Screenshot 2024-01-26 at 2 23 41 PM

Still works fine on this adhoc build.

Screenshot 2024-01-26 at 2 24 42 PM

So possible cases:

  • only happening on debug build
  • adhoc apk above is not built correctly
  • not caused by this PR

@chrispader
Copy link
Contributor Author

chrispader commented Jan 26, 2024

@chrispader can you please check this urgently?

So possible cases:

  • only happening on debug build
  • adhoc apk above is not built correctly
  • not caused by this PR

when building, did you delete your node_modules and run a fresh npm i before building android?

@chrispader
Copy link
Contributor Author

@situchan i just deleted node_modules, ran npm i and built Android from scratch, and i don't see this issue:

Screenshot_1706263052

@chrispader
Copy link
Contributor Author

The problem you're experiencing is most likely to the patch (that was removed in this PR) still being applied.

I might want to post a Slack message to #expensify-open-source to remove node_modules and re-install, if anyone is experiencing this.

Could you check if that solution works for you? @situchan

@situchan
Copy link
Contributor

@situchan i just deleted node_modules, ran npm i and built Android from scratch, and i don't see this issue:

Screenshot_1706263052

Same worked for me. Sorry for confusion.
I believe many devs will report this in slack.

@situchan
Copy link
Contributor

It took 15 min to build android. Much faster 👍

@situchan
Copy link
Contributor

I might want to post a Slack message to #expensify-open-source to remove node_modules and re-install, if anyone is experiencing this.

Agree

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/AndrewGable in version: 1.4.33-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 cancelled 🔪
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 1.4.33-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.