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

Feature: Tooltip for QAB #40066

Merged
merged 62 commits into from
Jun 19, 2024
Merged

Conversation

tienifr
Copy link
Contributor

@tienifr tienifr commented Apr 11, 2024

Details

Display a tooltip the first time the QAB is set.

Fixed Issues

$ #38054
PROPOSAL: #38054 (comment)

Tests

  1. Press FAB
  2. Verify the tooltip appears above quick action shortcut
  3. Verify that after 5 seconds, the tooltip disappears
  4. Press the quick action shortcut and complete its flow
  5. Press FAB
  6. Verify the tooltip does not appear
  • Verify that no errors appear in the JS console

Offline tests

NA

QA Steps

  1. Press FAB
  2. Verify the tooltip appears above quick action shortcut
  3. Verify that after 5 seconds, the tooltip disappears
  4. Press the quick action shortcut and complete its flow
  5. Press FAB
  6. Verify the tooltip does not appear
  • 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 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.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 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.
  • 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

Screenshot_1712893017

Android: mWeb Chrome

Screenshot_1713510515

iOS: Native

Simulator Screenshot - iPhone 15 Pro Max - 2024-04-19 at 14 01 42

iOS: mWeb Safari

simulator_screenshot_AA67AD81-D6E7-415F-92F7-6E154DB6A563

MacOS: Chrome / Safari

Screenshot 2024-04-19 at 14 04 55

MacOS: Desktop

Screenshot 2024-04-25 at 02 38 27

@trjExpensify
Copy link
Contributor

Niceee! Will we be able to put this into review today?

@tienifr tienifr marked this pull request as ready for review April 11, 2024 16:51
@tienifr tienifr requested review from a team as code owners April 11, 2024 16:51
@melvin-bot melvin-bot bot requested review from cubuspl42 and removed request for a team April 11, 2024 16:51
Copy link

melvin-bot bot commented Apr 11, 2024

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

@@ -602,6 +602,10 @@ export default {
trackManual: 'Crear Gasto',
trackScan: 'Crear Recibo',
trackDistance: 'Crear Gasto por desplazamiento',
tooltip: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy was verified here.

if (!shouldRenderWithoutHover) {
return;
}
const childrenRect = e.nativeEvent.target?.getBoundingClientRect();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The event target here is specific to react-native-web only.

}, []);

useEffect(() => {
const intervalID = setInterval(hideTooltip, 5000);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no observable user interaction to close this tooltip (cannot hover on mobile devices) so I assume that it should be closed in 5 seconds. Need design feedback here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dubielzyk-expensify, whatcha' think? I think 5 seconds is fine.

Copy link
Contributor Author

@tienifr tienifr Apr 12, 2024

Choose a reason for hiding this comment

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

You can refer to the iOS Native screenshots in PR description to have a better sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

That feels right to me as long as it dismissed on any tap anyways.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, any tap in the GC menu navigates you onwards to another page so it should be dismissed.

@dubielzyk-expensify
Copy link
Contributor

I like the little zoom out animation, but could we try it coming from the origin on where the pointing tip is? Feels a bit more correct

@shawnborton
Copy link
Contributor

@dubielzyk-expensify does this font size match your mocks? It looks like the tooltip font size is using normal font size which is 15px... just checking in case you intended for it to use the label size at 13px:
CleanShot 2024-04-12 at 10 13 18@2x

@@ -3674,6 +3674,22 @@ const styles = (theme: ThemeColors) =>
...wordBreak.breakWord,
},

quickActionTooltipWrapper: {
backgroundColor: colors.green100,
Copy link
Contributor

Choose a reason for hiding this comment

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

cc @dubielzyk-expensify - are you thinking to use the same background color across themes?

Either way, I think we should make this a variable that is stored in both themes, basically treating it like any other color style we use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I forgot to ask you about this. I couldn't get the exact color hex from the mockup.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we go with the one specified above, then yes, I was gonna keep the same look regardless of theme as it feels good in both light and dark mode

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay sweet, thanks for confirming. Even though they are the same across both themes, I think we should still take the same approach we do for all other colors here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also noting that we do have existing tooltip styles, so maybe we can consider this an extension of that... like highlightTooltip or something?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that idea!

quickActionTooltipTitle: {
fontFamily: FontUtils.fontFamily.platform.EXP_NEUE_BOLD,
fontWeight: FontUtils.fontWeight.bold,
fontSize: variables.fontSizeNormal,
Copy link
Contributor

Choose a reason for hiding this comment

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

cc @dubielzyk-expensify in case this should be label and not normal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep should be label

fontWeight: FontUtils.fontWeight.bold,
fontSize: variables.fontSizeNormal,
lineHeight: variables.lineHeightXLarge,
color: colors.green500,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above, we should make these theme-friendly color values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this color does not differ between the themes, should we make them theme-friendly? Otherwise can you give me the mockup in light mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And I need the exact color of the text here as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

If this color does not differ between the themes, should we make them theme-friendly?

My vote is yes, in case we ever add a 3rd theme or make these theme dependent in the future.

fontFamily: FontUtils.fontFamily.platform.EXP_NEUE_BOLD,
fontWeight: FontUtils.fontWeight.bold,
fontSize: variables.fontSizeNormal,
lineHeight: variables.lineHeightXLarge,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a huge line height here? I would think we could just vertically center the text via flex or use inner padding instead? I don't feel strongly though. Curious what we are using in the Figma.

@dubielzyk-expensify
Copy link
Contributor

It looks like the tooltip font size is using normal font size which is 15px... just checking in case you intended for it to use the label size at 13px:

The intent was to use label correct. Happy to have that opinion challenged though.

As for the background color I think we could potentially look into a variant if it doesn't fit what we want:
image

@shawnborton
Copy link
Contributor

Ah to be clear, I'm not challenging your font choice or background choice. I was just confirming that the font choice in this PR was correct, and it looks like it wasn't. I'm down with 13px.

Then for your background color, again I'm cool with what it looks like but just wanted to confirm if it changes across themes or not? What does the light mode version look like?

@dubielzyk-expensify
Copy link
Contributor

What does the light mode version look like?

image

@@ -0,0 +1,137 @@
import React, {useEffect, useMemo, useRef, useState} from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

File-scoped comment.

The amount of duplication between index.tsx and index.native.tsx is unacceptable. This is a big one.

Likely, there's a tough refactoring ahead of us.

Copy link
Contributor Author

@tienifr tienifr Apr 12, 2024

Choose a reason for hiding this comment

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

The amount of duplication between index.tsx and index.native.tsx is unacceptable. This is a big one.

I have thought about this a lot but this is just a temporary fix for the current expected behavior. The tooltip's position logic is really complicated and it's very hard to mimic all that for native platforms. For example, I eliminated shouldShowBelow check and horizontalShift calculations.

But as the mockup here implied, I think they would want to make all that behaviors work on native in the future. So I think seperating these files is neccessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not saying that we don't need any platform-splitting to *.tsx and *.native.tsx files, or that we need to implement all complex features on Native that the general-case Web hover-on tooltips need. On Native we'll be showing only the "educational" tooltips.

For example, you correctly assumed that it's not required to dynamically resize tooltips, as educational tootlips likely won't need this behavior soon, or ever. In general, the hover-on tooltips can resize in corner cases.

Still, there are many code de-duplication techniques that can be applied here, even with the simplifications and shortcomings we accepted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please give this a try. I feel like little effort has been put into de-duplication here so far. But if you run out of ideas, let me know, as I'll likely be able to help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

HI @cubuspl42, I've tried it but considering the only difference between those files are how the wrapper and content are measure, and the complexity of the web implementation, I couldn't come up with a better solution. Could you please suggest me some approaches to speed things up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TooltipRenderedOnPageBody is still basically a copy-pasted component, though. We should use the same techniques in this case.

Deduplication for TooltipRenderedOnPageBody would be to lift these logic up to GenericTooltip but the bound measurement and getTooltipStyle must stay in the same component otherwise it would cause a state "unsynchronization" and cause #18189. I think that's the minimum logic required for everything to function properly and won't need deduplication.

Copy link
Contributor

Choose a reason for hiding this comment

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

How's about BaseGenericTooltip

Semantically, I don't think it's that's a lucky choice. In this case, we're not only having yet-another-layer of component that's actually used to render the same chunk of UI eventually. Remember that the name Tootlip was always meaning the tooltip target wrapper, while TooltipRenderedOnPageBody was focused on realizing the actual tooltip wrapper & content.

image

Pragmatically, we have another problem. As I'm challenging the amount of duplication in this new TooltipRenderedOnPageBody replacement (let's call it RenderedTooltip for this reasoning), the solution might involve creating BaseRenderedTooltip, while BaseBaseGenericTooltip sounds kind of mad.

So I'd vote for some Base-less Generic-less name, and RenderedTooltip sounded like a minimal change, just throwing out the DOM-specific aspect (OnPageBody / on page <body>).

Copy link
Contributor

Choose a reason for hiding this comment

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

What also somehow bothers me is that BaseFoo can mean anything, it just says "well, Foo was taken 🤷‍♂️". It's either because we want a BaseFoo optionally-rendered by Foo , it can also be cross-platform BaseFoo, where actual platform-specific Foo injects some delegates, and here it's just a BaseFoo rendered in another cooridante space, owned by Foo. It's a naming mess, in my opinion. I wouldn't add to it if possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

In our case, number 2 (base foo = cross-platform foo) collides with number 3 (base foo = different coords foo)

Copy link
Contributor

Choose a reason for hiding this comment

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

@tienifr, we could at least lift this rendering logic up to a generic component, what do you think?
image

@trjExpensify
Copy link
Contributor

@eVoloshchak @Gonals can we get feedback to @tienifr on the above, please?

@tienifr
Copy link
Contributor Author

tienifr commented Jun 10, 2024

I'm still testing its feasibility. Anyway, it still seems overkill. I'll push the latest changes today.

@trjExpensify
Copy link
Contributor

Thanks, please do!

@pecanoro
Copy link
Contributor

Any news on this? We also got a new conflicts 😄

@trjExpensify
Copy link
Contributor

@tienifr I see commits, is it ready for @eVoloshchak to take another look? 🙏

@tienifr
Copy link
Contributor Author

tienifr commented Jun 13, 2024

Something was wrong with the popover size on main:

Simulator Screenshot - iPhone 15 Pro Max - 2024-06-14 at 00 43 48

But I resolved the issue with animationOutTiming above by calling hideTooltip in popover's onClose. @eVoloshchak This is ready for your review again.

@tienifr
Copy link
Contributor Author

tienifr commented Jun 13, 2024

Check failures are not related to this PR.

@Gonals
Copy link
Contributor

Gonals commented Jun 18, 2024

Seems like we have some conflicts

@tienifr
Copy link
Contributor Author

tienifr commented Jun 18, 2024

All set! Awaiting input from @eVoloshchak.

Copy link
Contributor

@eVoloshchak eVoloshchak left a comment

Choose a reason for hiding this comment

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

Tests well
Awesome job, @tienifr!

@melvin-bot melvin-bot bot requested a review from pecanoro June 18, 2024 15:43
@trjExpensify
Copy link
Contributor

@Gonals @pecanoro 👀 👀 🙏

@Gonals Gonals merged commit e213e89 into Expensify:main Jun 19, 2024
16 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.

@pecanoro
Copy link
Contributor

@Gonals You could have waited for my final review 😞

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Gonals in version: 1.4.86-0 🚀

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

1 similar comment
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Gonals in version: 1.4.86-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Gonals in version: 1.4.86-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/AndrewGable in version: 9.0.0-9 🚀

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.

10 participants