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

phase1: fix emoji picker refocus issue #35572

Merged
merged 23 commits into from
Apr 5, 2024

Conversation

ntdiary
Copy link
Contributor

@ntdiary ntdiary commented Feb 1, 2024

Details

Fixed Issues

$ #29011
PROPOSAL: #29011 (comment)

Tests

Note: For the iOS Safari platform, it only focuses without opening the keyboard, which is another separate issue and is beyond the scope.

  1. Send a message in any chat in App.
  2. Long press the message and tap on Edit message.
  3. Tap on the emoji picker.
  4. Select an emoji and verify the keyboard will open up.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests

QA Steps

Same as Tests

  • 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
35572-android-native.mp4
Android: mWeb Chrome
35572-android-chrome.mp4
iOS: Native
35572-ios-native.mp4
iOS: mWeb Safari
35572-ios-safari.mp4
MacOS: Chrome / Safari
35572-web.mp4
MacOS: Desktop
35572-desktop.mp4

@ntdiary ntdiary marked this pull request as ready for review February 1, 2024 17:19
@ntdiary ntdiary requested a review from a team as a code owner February 1, 2024 17:19
@melvin-bot melvin-bot bot requested review from parasharrajat and removed request for a team February 1, 2024 17:19
Copy link

melvin-bot bot commented Feb 1, 2024

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

@Julesssss
Copy link
Contributor

Hey @parasharrajat I believe this is the first PR related to this issue.

@parasharrajat
Copy link
Member

Thanks. Sure, I will get into this.

src/libs/ComposerFocusManager.ts Outdated Show resolved Hide resolved
src/components/EmojiPicker/EmojiPicker.js Show resolved Hide resolved
src/libs/ComposerFocusManager.ts Outdated Show resolved Hide resolved
src/libs/ComposerFocusManager.ts Outdated Show resolved Hide resolved
src/components/Modal/ModalContent.tsx Show resolved Hide resolved
@getusha
Copy link
Contributor

getusha commented Feb 20, 2024

@ntdiary i'm trying to get as much context i can, so this PR (phase1) only handles the case described in the PR right?

@ntdiary
Copy link
Contributor Author

ntdiary commented Feb 20, 2024

@ntdiary i'm trying to get as much context i can, so this PR (phase1) only handles the case described in the PR right?

@getusha, yeah. :)

@parasharrajat
Copy link
Member

FYI, I am back from OOO so I can pick up this PR.

Copy link
Contributor

@getusha getusha left a comment

Choose a reason for hiding this comment

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

small changes.

src/libs/ComposerFocusManager.ts Outdated Show resolved Hide resolved
src/CONST.ts Outdated Show resolved Hide resolved
src/components/Modal/ModalContent.tsx Show resolved Hide resolved
src/libs/ComposerFocusManager.ts Outdated Show resolved Hide resolved
src/libs/ComposerFocusManager.ts Outdated Show resolved Hide resolved
src/libs/ComposerFocusManager.ts Outdated Show resolved Hide resolved
let focusedInput: InputElement = null;
let uniqueModalId = 1;
const focusMap = new Map<ModalId, FocusMapValue>();
const activeModals: ModalId[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const activeModals: ModalId[] = [];
const activeModals = new Set<ModalId>();

I feel like a set suits our usecase best than an array & will help us simplify the code, will share full code if you want, will require some changes to the whole code :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like a set suits our usecase best than an array & will help us simplify the code, will share full code if you want, will require some changes to the whole code :)

We still need to get the index of the modalId in the queue, and the last element in the queue. not sure, could Set conveniently fulfill this requirement? 🤔

BTW, I also wanted to use Array.at, but based on the caniuse data, I'm a bit concerned about its compatibility unless we can add polyfill. 😂

image

Copy link
Contributor

@getusha getusha Feb 27, 2024

Choose a reason for hiding this comment

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

We still need to get the index of the modalId in the queue, and the last element in the queue. not sure, could Set conveniently fulfill this requirement? 🤔

Interesting, will have a deeper look, i thought it would be the most suitable

BTW, I also wanted to use Array.at, but based on the caniuse data, I'm a bit concerned about its compatibility unless we can add polyfill. 😂

i think, we already use babel-polyfill, wouldn't that also handle this? we're using it most of the places.

src/libs/ComposerFocusManager.ts Outdated Show resolved Hide resolved
src/libs/ComposerFocusManager.ts Outdated Show resolved Hide resolved
@getusha
Copy link
Contributor

getusha commented Feb 27, 2024

Testing

@getusha
Copy link
Contributor

getusha commented Feb 28, 2024

@ntdiary i can notice a kind of swift glitch (switching focus from the second input)

  1. Send two messages
  2. Edit the two messages
  3. Focus the above input
  4. Open the emoji picker from the bottom input
  5. Close the emoji picker
video_2024-02-28_09-33-43.mp4

@getusha
Copy link
Contributor

getusha commented Feb 28, 2024

Similar case as ^, focus the second input, open emoji picker on the above input and pick an emoji
Emoji will be inserted on the first input but the second one is focused. not reproducible on prod.

video_2024-02-28_09-40-15.mp4

@getusha
Copy link
Contributor

getusha commented Feb 28, 2024

BUG: focus not restored after opening profile details page

  1. Send a message
  2. Long press > Edit
  3. Make sure the input is focused
  4. Press the header of the room/chat
  5. Press the back button
video_2024-02-28_09-43-06.mp4

@getusha
Copy link
Contributor

getusha commented Mar 27, 2024

Did you test it on Android 14 (API 34)? I noticed that the android native code can pull up the keyboard after closing the modal, but for versions before android 14, the issue still persists (I test on Android 13 / API 33).

Able to reproduce on lower versions :)

Screen.Recording.2024-03-27.at.5.53.09.in.the.afternoon.mov

@getusha
Copy link
Contributor

getusha commented Mar 27, 2024

Will test it on several devices.

@getusha
Copy link
Contributor

getusha commented Mar 28, 2024

BUG: Cursor is placed before the inserted emoji (Not able to reproduce on staging)

  1. Edit any message
  2. Open the emoji picker
  3. Insert one emoji
Screen.Recording.2024-03-28.at.1.54.36.in.the.afternoon.mov

BUG: Inserting emoji on composer crashes the app (mWeb android)

  1. Open any chat
  2. Open emojipicker
  3. Insert an emoji
Screen.Recording.2024-03-28.at.1.55.56.in.the.afternoon.mov

@ntdiary
Copy link
Contributor Author

ntdiary commented Apr 1, 2024

@getusha, have fixed the selection bug, can't reproduce the crash bug. If you can reproduce it, it would be great if you can also provide the os version and chrome version ,and then I can try again. :)

@getusha
Copy link
Contributor

getusha commented Apr 4, 2024

@getusha, have fixed the selection bug, can't reproduce the crash bug. If you can reproduce it, it would be great if you can also provide the os version and chrome version ,and then I can try again. :)

it's probably a conflict, checking again.

Copy link
Contributor

@getusha getusha left a comment

Choose a reason for hiding this comment

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

Code looks good testing.

@getusha
Copy link
Contributor

getusha commented Apr 4, 2024

Keyboard is not opening after closing the popover from top right button

Screen.Recording.2024-04-04.at.2.25.06.in.the.afternoon.mov

@getusha
Copy link
Contributor

getusha commented Apr 4, 2024

Same for request money

Screen.Recording.2024-04-04.at.2.27.23.in.the.afternoon.mov

@ntdiary
Copy link
Contributor Author

ntdiary commented Apr 4, 2024

Keyboard is not opening after closing the popover from top right button
Same for request money

@getusha, do you think these two issues are regressions caused by this PR? So far, we only fixed the emoji modal case to make the PR reviews easier. 😂

@getusha
Copy link
Contributor

getusha commented Apr 4, 2024

@getusha, do you think these two issues are regressions caused by this PR? So far, we only fixed the emoji modal case to make the PR reviews easier. 😂

Oh mb, since we linked the issue, i was testing the cases you listed #29011 (comment)

@melvin-bot melvin-bot bot requested a review from Julesssss April 4, 2024 16:28
@Julesssss
Copy link
Contributor

Hey @ntdiary would you mind merging main to resolve conflicts once more please

@ntdiary
Copy link
Contributor Author

ntdiary commented Apr 5, 2024

Hey @ntdiary would you mind merging main to resolve conflicts once more please

Have just merged. 😄

Copy link
Contributor

github-actions bot commented Apr 5, 2024

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

testing well to me based on our most recent requirements

@Julesssss Julesssss merged commit 5da3daf into Expensify:main Apr 5, 2024
15 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Apr 5, 2024

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

@OSBotify
Copy link
Contributor

OSBotify commented Apr 8, 2024

🚀 Deployed to staging by https://github.com/Julesssss in version: 1.4.61-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Apr 8, 2024

🚀 Deployed to staging by https://github.com/Julesssss in version: 1.4.61-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 1.4.61-8 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 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.

5 participants