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

Fix the edit comment input getting focus when long-pressing on Android #13593

Merged
merged 6 commits into from
Dec 15, 2022

Conversation

tgolen
Copy link
Contributor

@tgolen tgolen commented Dec 14, 2022

Fixed Issues

$ #11048

Tests

Mobile platforms:

  1. Go into a chat where you sent a message
  2. Long-press on the message and select edit
  3. Verify that the keyboard is open and you can edit the comment

Non-mobile platforms:

  1. Go into a chat where you sent a messages
  2. Hover over the messages and click on the edit button in the context menu
  3. Verify that the edit comment button has focus and you can edit it
  • Verify that no errors appear in the JS console

Offline tests

Same as above. There should be no difference in behavior

QA Steps

Same as above.

  • 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:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 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
    • 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 correct English and 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 a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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(themeColors.componentBG)
  • 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 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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
2022-12-14_12-40-37.mp4
Mobile Web - Chrome
2022-12-14_12-39-24.mp4
Mobile Web - Safari
2022-12-14_12-49-25.mp4
Desktop
2022-12-14_12-42-09.mp4
iOS
2022-12-14_12-48-22.mp4
Android
2022-12-14_12-38-34.mp4

@tgolen tgolen requested a review from a team as a code owner December 14, 2022 19:55
@tgolen tgolen self-assigned this Dec 14, 2022
@melvin-bot melvin-bot bot requested review from AndrewGable and thesahindia and removed request for a team December 14, 2022 19:55
@melvin-bot
Copy link

melvin-bot bot commented Dec 14, 2022

@AndrewGable @thesahindia One of you needs to 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]

src/libs/focusTextInputAfterAnimation/index.android.js Outdated Show resolved Hide resolved
this.textInput.focus();
// There is an animation when the comment is hidden and the edit form is shown, and there can be bugs on different mobile platforms
// if the input is given focus in the middle of that animation which can prevent the keyboard from opening.
focusTextInputAfterAnimation(this.textInput, 10);
Copy link
Member

Choose a reason for hiding this comment

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

I was testing this at physical android device and I experienced that the edit composer shakes a lit bit sometimes and sometimes the keyboard doesn't open

Screenrecording_20221215_154054.mp4

I think we can increase the delay. Maybe let's use 100ms same as here

setTimeout(() => this.textInput.focus(), 100);

At 100ms -

Screenrecording_20221215_164307.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, thank you for that testing! I originally had it set to 100, but I was only testing on an emulator (all I have access to) and it worked consistently at 10ms. I'm fine increasing that to 100 👍

@tgolen
Copy link
Contributor Author

tgolen commented Dec 15, 2022

Updated

@thesahindia
Copy link
Member

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 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
    • 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 correct English and 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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(themeColors.componentBG)
  • 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 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Screen.Recording.2022-12-15.at.11.37.43.PM.mov
Mobile Web - Chrome
video_20221215_233711_edit.mp4
Mobile Web - Safari

Couldn't test this because my ip changed and it needs to be added to the whitelist again😔

Desktop
Screen.Recording.2022-12-15.at.11.15.40.PM.mov
iOS
Screen.Recording.2022-12-16.at.12.05.09.AM.mov
Android
Screenrecording_20221215_234351.mp4

Copy link
Member

@thesahindia thesahindia left a comment

Choose a reason for hiding this comment

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

Works well for me!

C+ reviewed 🎀👀🎀

All yours @AndrewGable

@AndrewGable AndrewGable merged commit 18983f8 into main Dec 15, 2022
@AndrewGable AndrewGable deleted the tgolen-fix-edit-comment-focus branch December 15, 2022 22:03
@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.

@github-actions
Copy link
Contributor

Performance Comparison Report 📊

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Duration
TTI 818.205 ms → 840.394 ms (+22.189 ms, +2.7%)
runJsBundle 192.844 ms → 200.000 ms (+7.156 ms, +3.7%)
regularAppStart 0.014 ms → 0.015 ms (+0.001 ms, +5.4%)
nativeLaunch 10.742 ms → 9.867 ms (-0.875 ms, -8.1%)
Show details
Name Duration
TTI Baseline
Mean: 818.205 ms
Stdev: 39.123 ms (4.8%)
Runs: 750.5827810000628 764.436507999897 767.9401400000788 776.1787300000433 779.4557739999145 779.8709239999298 784.9772280000616 787.0693590000737 795.8957209999207 798.759056000039 799.0215720001142 799.9495459999889 807.802643999923 808.3741729999892 811.5405550000723 815.7719620000571 815.94239500002 816.15574200009 824.1126059999224 825.3317050000187 826.6914619999006 829.6414469999727 831.4113580000121 838.3085509999655 849.5160819999874 862.0149630000815 862.1380729998928 865.411110999994 865.5793769999873 890.4230390000157 934.0539279999211

Current
Mean: 840.394 ms
Stdev: 35.576 ms (4.2%)
Runs: 754.2906229998916 787.7052269999404 791.4778020000085 795.0072910001036 803.5659280000255 809.589660000056 811.4895999999717 814.192839999916 818.155449999962 824.4602109999396 828.7108569999691 829.3189729999285 831.5727309999056 831.8294599999208 835.460570000112 839.0946669999976 841.1398680000566 844.9977480000816 850.9210489999969 852.4145070000086 854.9498129999265 861.0380569999106 863.0084430000279 865.7989529999904 867.6118520000018 881.96629199991 882.5237129998859 884.1937080000062 884.422212000005 884.5325160000939 926.7688869999256
runJsBundle Baseline
Mean: 192.844 ms
Stdev: 19.524 ms (10.1%)
Runs: 160 166 169 170 172 172 173 175 176 180 182 182 186 188 190 190 190 192 192 195 198 199 203 207 212 216 216 218 218 219 228 237

Current
Mean: 200.000 ms
Stdev: 22.383 ms (11.2%)
Runs: 167 168 169 171 174 178 178 179 180 182 188 189 190 191 198 199 201 203 205 206 208 210 210 211 215 223 225 228 229 231 244 250
regularAppStart Baseline
Mean: 0.014 ms
Stdev: 0.001 ms (4.1%)
Runs: 0.013020999962463975 0.013224000111222267 0.013265000190585852 0.013346999883651733 0.013386999955400825 0.0134680001065135 0.013469000114127994 0.013550000032410026 0.013590000104159117 0.013590000104159117 0.013752999948337674 0.01383400009945035 0.013916000025346875 0.013956999871879816 0.0139979999512434 0.014161000028252602 0.014200999867171049 0.014201000100001693 0.014282000018283725 0.014283000025898218 0.01432300009764731 0.01432300009764731 0.014444999862462282 0.01448600017465651 0.014607999939471483 0.014648000011220574 0.014648999786004424 0.0148930000141263 0.014973999932408333 0.015096999937668443 0.015176999848335981

Current
Mean: 0.015 ms
Stdev: 0.001 ms (6.2%)
Runs: 0.013550000032410026 0.01359100011177361 0.013630999950692058 0.013630999950692058 0.013672000030055642 0.013875000178813934 0.013916000025346875 0.013996999943628907 0.014038000022992492 0.014078999869525433 0.014282000018283725 0.014282000018283725 0.014445000095292926 0.01460699993185699 0.014607000164687634 0.014771000016480684 0.014973999932408333 0.015055000083521008 0.015096000162884593 0.015096000162884593 0.015137000009417534 0.01521800016053021 0.015503000002354383 0.015625 0.015664999838918447 0.015706000151112676 0.01595099992118776 0.016072999918833375 0.01615400006994605 0.016561000142246485 0.01672299997881055
nativeLaunch Baseline
Mean: 10.742 ms
Stdev: 2.257 ms (21.0%)
Runs: 8 8 8 8 8 9 9 9 9 9 9 9 10 10 10 11 11 11 11 11 11 12 12 13 13 13 13 13 13 14 18

Current
Mean: 9.867 ms
Stdev: 1.500 ms (15.2%)
Runs: 8 8 8 8 8 8 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 11 11 11 11 12 12 13 14

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @AndrewGable in version: 1.2.41-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @AndrewGable in version: 1.2.41-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @yuwenmemon in version: 1.2.41-4 🚀

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

@perunt perunt mentioned this pull request Mar 28, 2023
53 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants