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 clickable custom emoji support for onboarding task #55222

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Amoralchik
Copy link
Contributor

@Amoralchik Amoralchik commented Jan 14, 2025

Explanation of Change

Add clickable custom emoji support for onboarding task

Fixed Issues

$ #54643
PROPOSAL: #54643 (comment)

Tests

  1. Login with new account
  2. Click the "Submit expense" task from Concierge
  3. Make sure you can see a green emoji-like button inline with the text
  4. Make sure you can click green button and finish Task (Create expense)

Offline tests

QA Steps

  1. Create new account
  2. Choose "Get paid back by my employer" option in onboarding
  3. Click the "Submit expense" task from Concierge
  4. Make sure you can see a green emoji-like button inline with the text
  5. Make sure you can click green button and finish Task (Create expense)

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 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 used JaimeGPT to get English > Spanish translation. I then posted it 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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.ts 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 UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design 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.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • 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
2025-01-21.21.43.00.mov
Android: mWeb Chrome
2025-01-21.19.59.54.mov
iOS: Native
2025-01-21.20.54.08.mov
iOS: mWeb Safari
2025-01-21.20.55.36.mov
MacOS: Chrome / Safari
2025-01-21.19.35.32.mov
MacOS: Desktop
2025-01-21.19.43.45.mov

@Amoralchik Amoralchik force-pushed the clickable-emoji-in-expense-task branch from dfc6476 to a61a8d5 Compare January 16, 2025 11:35
@Amoralchik Amoralchik marked this pull request as ready for review January 16, 2025 14:16
@Amoralchik Amoralchik requested review from a team as code owners January 16, 2025 14:16
@melvin-bot melvin-bot bot requested review from c3024 and removed request for a team January 16, 2025 14:16
Copy link

melvin-bot bot commented Jan 16, 2025

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

@Amoralchik Amoralchik force-pushed the clickable-emoji-in-expense-task branch from a61a8d5 to c446d64 Compare January 16, 2025 14:21
@dannymcclain
Copy link
Contributor

Hmm, I like the inclusion of the green plus button image... But I don't know how I feel about it being clickable and actually opening the GC menu. @Expensify/design how do you all feel about that? Was that decision made in a convo somewhere that I missed?

@shawnborton
Copy link
Contributor

The relevant conversation is here.

I have mixed feelings. I don't love that this is kind of a "new" way to make an expense, but at the same time, I understand the need to educate our users. If it were up to me I would probably not do this one though, but others seemed to have felt strongly.

@@ -1658,6 +1658,15 @@ const styles = (theme: ThemeColors) =>
justifyContent: 'center',
},

floatingActionEmoji: {
Copy link
Contributor

Choose a reason for hiding this comment

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

cc @Expensify/design - part of me thinks we should just provide an .svg image for this rather than creating a custom element via styles.

@Amoralchik is there a reason why you didn't do this via an svg?

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 not good at SVG, and because floatingActionButton already use two SVG elements, I decided to simply resize it

Copy link
Contributor

Choose a reason for hiding this comment

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

The design team will provide the svg. But I think it's implementation would be far simpler, and kind of paves the path for future custom emojis should we want more.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we might want to use a 20x20 frame, but inside of it use a 18x18 button so we get a little bit of space around the shape in case to prevent collisions with lines that may appear before/after. Basically the option on the right seems like it would be better to me:
CleanShot 2025-01-16 at 16 42 45@2x

Copy link
Contributor

Choose a reason for hiding this comment

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

@Amoralchik can you try with this image quickly? custom-emoji__global-create.svg.zip

Note that the svg is 20px tall, and the line height of the text surrounding it is also 20px tall. So it should all line up perfectly like this:
CleanShot 2025-01-16 at 16 45 10@2x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shawnborton Hello, sorry for the wait. I’ve rewritten the code using the SVG icon you provided. I feel like I might not have fully understood what you meant, so here is the result with 18px and 20px sizes.

Before :
image

After:
With icon size 20px
image

With icon size 18px
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah sorry, please use the icon I provided to you at 20px. What I did was make the inner green circle 18px within a 20px bounding box. Let me know if that makes sense.

Copy link
Contributor Author

@Amoralchik Amoralchik Jan 17, 2025

Choose a reason for hiding this comment

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

@shawnborton Okay, I updated the code using an icon size of 20px. I was wondering if it might be worth increasing the size of the "+" icon. I know it might just be me, but I sometimes find it a bit hard to see it against a green circle.

I mean that this icon currently just replicates the main one, which is probably correct, but I think some people might find it hard to notice the "+" on a phone screen or a very large monitor.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's see what the other designers think, cc @Expensify/design

Personally I think it's fine because it's basically just a scaled down version of the existing global create, so it basically has the same proportions that the normal button has. I can see wanting to correct it optically a little bit, but it doesn't bother me personally.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see wanting to correct it optically a little bit, but it doesn't bother me personally.

This is pretty much exactly how I feel. I think it's probably fine as-is, so maybe we wait and see if we receive any feedback about it before changing it? Seems like a simple change to replace the SVG in the future if we think we need to.

@dannymcclain
Copy link
Contributor

If it were up to me I would probably not do this one though, but others seemed to have felt strongly.

Ok thank you for the context! I guess I was involved in that convo and just didn't realize we were planning to add that functionality. I would prefer it to not have it, but I won't stand in the way.

@quinthar
Copy link
Contributor

Just to confirm, this is kind of two totally different features at work:

  1. We are adding a :global-create: emoji.
  2. We are adding a expensify://global-create URL

These are completely distinct, unrelated features, that happen to work well together (ie, if you hyperlink :global-create: and use that URL, it'll open it). Just making sure we aren't doing something special to make that emoji have some kind of magic side effect everywhere it appers.

@shawnborton
Copy link
Contributor

Just making sure we aren't doing something special to make that emoji have some kind of magic side effect everywhere it appears.

@quinthar is there something happening in this PR that caused you to make that comment? Just want to make sure I am understanding your concern correctly.

@c3024
Copy link
Contributor

c3024 commented Jan 20, 2025

@quinthar

The FAB does not have a screen. So, based on the Slack discussion, creating a link solely to open the FAB is odd. So, we are using custom renderers to open the popover as well when there is no screen associated with the popover.

When we want to simulate a button click to open a popover that does not have a screen (like the FAB in this case) for an emoji, we will use a default press attribute in the custom-emoji to make the emoji clickable.

We are adding a :global-create: emoji.
We are adding an expensify://global-create URL.
These are completely distinct, unrelated features that happen to work well together (i.e., if you hyperlink :global-create: and use that URL, it’ll open it).

For emojis linking to routes that exist, this is exactly how we do it:

[<custom-emoji emoji="emoji-name" />](URL)

However, when there is no URL or screen for the action triggered by clicking the emoji, we use:

<custom-emoji emoji="emoji-name" pressablewithdefault />

When the pressablewithdefault attribute is present, we attach a default onPress handler that opens the popover to the emoji. In the present case, we set the FAB visibility with this onPress handler.

Just making sure we aren't doing something special to make that emoji have some kind of magic side effect everywhere it appers.

So, this press effect does not appear everywhere the emoji is present but only at selective places where we pass the attribute.

@Amoralchik Amoralchik force-pushed the clickable-emoji-in-expense-task branch from f508b3b to b1e3dbc Compare January 20, 2025 18:00
@Amoralchik
Copy link
Contributor Author

Updated
SVG icon
Refactoring code
Android app crashes after updating from main branch, for other re-record videos and update description

@Amoralchik
Copy link
Contributor Author

Updated
Fix merge conflict

@shawnborton
Copy link
Contributor

Going to run a test build on this one.

Copy link
Contributor

🚧 @shawnborton has triggered a test build. You can view the workflow run here.

Copy link
Contributor

@shawnborton
Copy link
Contributor

The vertical alignment looks off:
CleanShot 2025-01-21 at 17 51 44@2x

Adding vertical-align: top seems to fix it at least?
CleanShot 2025-01-21 at 17 53 13@2x

@Amoralchik
Copy link
Contributor Author

@shawnborton I apologize for the inconvenience. There's little difference between the code on my laptop and PC, so the styles for the buttons are not being applied. This has been fixed.

@shawnborton
Copy link
Contributor

Okay great, let us know when you have updated screenshots for all of the platforms so we can review from there. Thanks!

@Amoralchik
Copy link
Contributor Author

Updated
Fixed Styles
All video rerecorded

@c3024
Copy link
Contributor

c3024 commented Jan 22, 2025

@Amoralchik

As specified here, we should be able to add custom emojis separately without necessarily having a default pressable action.

So, CustomEmojiRenderer should primarily render the custom emojis, and only in specific cases where we want a press action linked that does not have a route to the emoji should we add a default action.

IMO, we should minimize the changes to FABPopover and FAB components as well.

I made a branch with these ideas. Could you check it and update this PR in line with these requirements?

Feel free to ask if you have any questions.

Thanks!

@Amoralchik
Copy link
Contributor Author

Amoralchik commented Jan 22, 2025

@c3024

I like the idea of using useContext and a Provider, but there will be a complete change to the logic of FloatingActionButtonAndPopover.PopoverMenu must be located elsewhere and accessible from any screen (for phones and small windows).

In short, FloatingActionButtonAndPopover must be rendered in the same place to be opened. In the current realization (in your and now in my branch), PopoverMenu is opened in the first screen where it is located. To fix that, FloatingActionButtonAndPopover will be just FloatingActionButton, which opens PopoverMenu that is moved to a place like provider.

I need your opinion before moving forward.

@c3024
Copy link
Contributor

c3024 commented Jan 23, 2025

@Amoralchik

PopoverMenu must be located elsewhere and accessible from any screen (for phones and small windows).

FAB stays mounted even on smaller screens as long as we are on the Central pane report screen. So, clicking on the + in the task description allows the popover to be shown over the report screen in smaller devices.

In short, FloatingActionButtonAndPopover must be rendered in the same place to be opened.

It opens at the same place as usual except that it is now not hidden for smaller screens and appears over the report pane in smaller screens.

Do you see any practical problems with opening the popover? Could you share a video of the issue you are seeing now?

@Amoralchik
Copy link
Contributor Author

@c3024 can't show it now (going to sleep), please can you try it on iOS, or android, and also try make small window in browser then reload the page, and try custom emoji, in my cases, it not open, or opened on the main page (where you can see the fab)

@c3024
Copy link
Contributor

c3024 commented Jan 23, 2025

Screen.Recording.2025-01-23.at.7.45.02.AM.mov

This change already included in popover menu should have fixed that

-isVisible={isCreateMenuActive && (!shouldUseNarrowLayout || isFocused)}
+isVisible={isCreateMenuActive}

can't show it now (going to sleep)

Sure, please update when you are back online!

@Amoralchik
Copy link
Contributor Author

Amoralchik commented Jan 23, 2025

@c3024 Here it is.
The problem has been fixed in the browser, but still got it on iOS.
I also got a warning about passing value to Provider in FABPopoverContext, so I wrapped it in useMemo.

2025-01-23.16.41.45-1-1.mov

Without this change FAB is still not openings:

2025-01-23.16.34.10-1-1-1.mov

@c3024
Copy link
Contributor

c3024 commented Jan 23, 2025

@Amoralchik

It worked for me on iOS. There should be no difference there too. Could you build the iOS app afresh and check?

@Amoralchik
Copy link
Contributor Author

@c3024
Unfortunately, I still can't get it to work on IOS.

It looks like it works fine on other platforms,

So what do you think? maybe you can provide a video, and I can update the description with other videos, and we can move forward with it

@Amoralchik Amoralchik force-pushed the clickable-emoji-in-expense-task branch from c8913e5 to ee33234 Compare January 24, 2025 20:04
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