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

Add Emoji Category Picker #14532

Merged
merged 59 commits into from
Feb 13, 2023
Merged

Add Emoji Category Picker #14532

merged 59 commits into from
Feb 13, 2023

Conversation

stitesExpensify
Copy link
Contributor

@stitesExpensify stitesExpensify commented Jan 25, 2023

Details

  • Adds an emoji category picker to all platforms
  • Updates Category Labels to match rest of app
  • Updates Web/Desktop search bar to match rest of app
  • Simplifies keyboard navigation offset calculations for web/desktop

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/239100

Tests

All Platforms

  1. Create a new account
  2. Choose any chat
  3. Open the emoji picker
  4. Make sure there is a category picker row with only 8 categories
  5. Click around on the different categories and make sure you are brought to the right place
  6. Choose any emoji
  7. Re-open the emoji picker and make sure that there are now 9 categories (including the frequently used category)
  8. Click around on the different categories and make sure you are brought to the right place

Web / Desktop

  1. Choose any chat
  2. Open the emoji picker
  3. Search and make sure the results are what you would expect
  4. Use the keyboard to navigate around the emojis and choose one
  5. Make sure nothing looks out of the ordinary
  • Verify that no errors appear in the JS console

Offline tests

n/a functionality is not affected by online/offline

QA Steps

All Platforms

  1. Create a new account
  2. Choose any chat
  3. Open the emoji picker
  4. Make sure there is a category picker row with only 8 categories
  5. Click around on the different categories and make sure you are brought to the right place
  6. Choose any emoji
  7. Re-open the emoji picker and make sure that there are now 9 categories (including the frequently used category)
  8. Click around on the different categories and make sure you are brought to the right place

Web / Desktop

  1. Choose any chat
  2. Open the emoji picker
  3. Search and make sure the results are what you would expect
  4. Use the keyboard to navigate around the emojis and choose one
  5. Make sure nothing looks out of the ordinary
  • 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 / Chrome
    • iOS / native
    • iOS / 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 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 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
2023-02-02_11-32-27.mp4
Mobile Web - Chrome
2023-02-02_11-51-46.mp4
Mobile Web - Safari
2023-02-02_11-50-22.mp4
Desktop
2023-02-02_11-53-39.mp4
iOS
2023-02-02_11-49-27.mp4
Android
2023-02-10_13-12-09.mp4

@stitesExpensify stitesExpensify self-assigned this Jan 25, 2023
@stitesExpensify
Copy link
Contributor Author

@Pujan92 I saw that you fixed the issue of the emoji picker jumping in this PR do you know what is going on here? The issue only appears to happen on mobile emulators.

iOS:
https://user-images.githubusercontent.com/42391420/214448522-9581084c-40f8-4af4-a89d-179cef955e96.mp4

@Pujan92
Copy link
Contributor

Pujan92 commented Jan 25, 2023

iOS: https://user-images.githubusercontent.com/42391420/214448522-9581084c-40f8-4af4-a89d-179cef955e96.mp4

@stitesExpensify Here as we are trying to scroll to the category header, we need to provide getItemLayout calculation to flatlist which skips the measurement of dynamic content. For the web I have added in that PR, you need to add the same for the native file.

diff --git a/src/components/EmojiPicker/EmojiPickerMenu/index.native.js b/src/components/EmojiPicker/EmojiPickerMenu/index.native.js
index bf9ac71bcf..cc4e46312a 100644
--- a/src/components/EmojiPicker/EmojiPickerMenu/index.native.js
+++ b/src/components/EmojiPicker/EmojiPickerMenu/index.native.js
@@ -111,6 +111,10 @@ class EmojiPickerMenu extends Component {
         this.emojiList.scrollToOffset({offset: testoffset, animated: false});
     }
 
+    getItemLayout(data, index) {
+        return {length: CONST.EMOJI_PICKER_ITEM_HEIGHT, offset: CONST.EMOJI_PICKER_ITEM_HEIGHT * index, index};
+    }
+
     /**
      * Given an emoji item object, render a component based on its type.
      * Items with the code "SPACER" return nothing and are used to fill rows up to 8
@@ -167,6 +171,7 @@ class EmojiPickerMenu extends Component {
                         this.isMobileLandscape() && styles.emojiPickerListLandscape,
                     ]}
                     stickyHeaderIndices={this.unfilteredHeaderIndices}
+                    getItemLayout={this.getItemLayout}
                 />

@stitesExpensify
Copy link
Contributor Author

Ah, I see, thank you. For some reason I thought it was added to both. Going back and looking, I see that we said it was only happening on web/desktop which is interesting... I'm glad the solution works across the board though

@stitesExpensify
Copy link
Contributor Author

That definitely helped, but there is still a bit of lag (could just be because of the emulator?).

I think that adding the animation makes it less noticible though:

No animation:
https://user-images.githubusercontent.com/42391420/214598369-9024f1b4-fe57-4d17-9e35-52832ca7dcf2.mp4

Animation:
https://user-images.githubusercontent.com/42391420/214598391-6f591c37-3298-4808-9075-83afa71731e8.mp4

@Pujan92
Copy link
Contributor

Pujan92 commented Jan 25, 2023

I don't think it is due to emulator, FlatList renders partial emojis at a time for a performance, so I think animation here will be beneficial.

Just to add we also need to adjust the height changes of the list otherwise scrolling with the arrow key may breaks.

Screenshot 2023-01-25 at 10 41 54 PM

@stitesExpensify
Copy link
Contributor Author

I don't think it is due to emulator, FlatList renders partial emojis at a time for a performance, so I think animation here will be beneficial.

Why would it only happen on the emulators and not on web/desktop then?

@aimane-chnaif
Copy link
Contributor

@stitesExpensify reanimated library is updated now. please pull from latest main

@stitesExpensify
Copy link
Contributor Author

reanimated library is updated now.

What does that mean @aimane-chnaif ?

Also, I updated native to reanimated, but just switched the web version to animated=true to match, and it fixed the iOS mobile web issue!

@aimane-chnaif
Copy link
Contributor

reanimated library is updated now.

What does that mean @aimane-chnaif ?

I mean version bump. #14946
You may face error. Here's reference to fix: https://expensify.slack.com/archives/C01GTK53T8Q/p1676046724064409

@stitesExpensify
Copy link
Contributor Author

Oh, are you saying because it was updated, we need to test again with the new version?

@aimane-chnaif
Copy link
Contributor

Oh, are you saying because it was updated, we need to test again with the new version?

Exactly

@stitesExpensify
Copy link
Contributor Author

Updated, and it still seems to be performing correctly!

@stitesExpensify
Copy link
Contributor Author

This is now ready for re-review!

Copy link
Contributor

@PauloGasparSv PauloGasparSv left a comment

Choose a reason for hiding this comment

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

LGTM!

Screenshots/Videos

Web
Web.mov
Mobile Web - Chrome
Android.Web.mov
Mobile Web - Safari
iOS.Web.mov
Desktop
Desktop.mov
iOS
iOS.mov
Android
Android.mov

@aimane-chnaif
Copy link
Contributor

Reviewing now

this.emojiList.scrollToOffset({offset: calculatedOffset, animated: false});
const node = findNodeHandle(this.emojiList);
runOnUI(() => {
'worklet';
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add comment what's it for? Similar to

// We are using the worklet directive here and running on the UI thread to ensure the Reanimated
// shared values are updated synchronously, as they update asynchronously on the JS thread.
'worklet';

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @aimane-chnaif IMO I don't think the comment will add value there. Will merge the P.R. here : )

@aimane-chnaif
Copy link
Contributor

Some feedback: (not new)

  • If 2 categories are tapped almost at the same time, both are highlighted. (android native)
feedback1.mp4
  • Scroll animation is not smooth (known issue, maybe lack of FlatList). Category title is also not updated smoothly. (android native)
feedback2.mp4
  • text is selected when long press category icon (iOS safari)
msafari.MP4
  • small margin between category list and section title (iOS safari)
msafari2.MP4

margin

Except these issues, the main feature tests well on all platforms.

@PauloGasparSv PauloGasparSv merged commit 6fcad7b into main Feb 13, 2023
@PauloGasparSv PauloGasparSv deleted the stites-emojiCategoryPicker branch February 13, 2023 16:37
@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.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/PauloGasparSv in version: 1.2.71-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 1.2.71-1 🚀

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants