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

[$250] Tooltip appeared on the global create disappear and did not appear back #54925

Open
1 of 8 tasks
m-natarajan opened this issue Jan 8, 2025 · 17 comments
Open
1 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@m-natarajan
Copy link

m-natarajan commented Jan 8, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.81-6
Reproducible in staging?: y
Reproducible in production?: y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @flaviadefaria
Slack conversation (hyperlinked to channel name): migrate

Action Performed:

  1. Login to ND
  2. Hover over the global FAB
  3. Tooltip appears
  4. Click on to the expense
  5. Hover on the global FAB

Expected Result:

tooltip should display again

Actual Result:

tooltip dismissed and never appears back

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
https://github.com/user-attachments/assets/1967b360-fca2-42eb-8a8e-f1ad9c4c1009

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021878927417137220974
  • Upwork Job ID: 1878927417137220974
  • Last Price Increase: 2025-01-13
Issue OwnerCurrent Issue Owner: @
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 8, 2025
Copy link

melvin-bot bot commented Jan 8, 2025

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@mallenexpensify
Copy link
Contributor

Need to test mobile app and mweb.

@ishpaul777
Copy link
Contributor

ishpaul777 commented Jan 8, 2025

@rayane-djouah will you be able to look for fix for this one?


@mallenexpensify me and @rayane-djouah will take over we are working on polish issues for #migrate project

@ishpaul777
Copy link
Contributor

still looking for fix this seems to be dupe (or atleast same root cause) of #54867

@melvin-bot melvin-bot bot removed the Overdue label Jan 10, 2025
@flaviadefaria flaviadefaria added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 10, 2025
@melvin-bot melvin-bot bot added the Overdue label Jan 13, 2025
@ishpaul777
Copy link
Contributor

awaiting proposals

@melvin-bot melvin-bot bot removed the Overdue label Jan 13, 2025
@mallenexpensify
Copy link
Contributor

me and @rayane-djouah will take over we are working on polish issues for #migrate project

@ishpaul777 , will you two be able to start work on this soon?

@mallenexpensify mallenexpensify removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 13, 2025
@ishpaul777
Copy link
Contributor

@mallenexpensify we aren't not able to figure this out, chatted with @rayane-djouah root cause is still unclear to us

so i asked to put "help wanted" here https://expensify.slack.com/archives/C07NMDKEFMH/p1736532130999349?thread_ts=1736462858.720569&cid=C07NMDKEFMH

@mallenexpensify mallenexpensify added the External Added to denote the issue can be worked on by a contributor label Jan 13, 2025
@melvin-bot melvin-bot bot changed the title Tooltip appeared on the global create disappear and did not appear back [$250] Tooltip appeared on the global create disappear and did not appear back Jan 13, 2025
Copy link

melvin-bot bot commented Jan 13, 2025

Job added to Upwork: https://www.upwork.com/jobs/~021878927417137220974

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 13, 2025
Copy link

melvin-bot bot commented Jan 13, 2025

Current assignees @rayane-djouah and @ishpaul777 are eligible for the External assigner, not assigning anyone new.

@linhvovan29546
Copy link
Contributor

@ishpaul777 @rayane-djouah I can reproduce this issue. I tested it with my proposal here, and the issue is resolved.

@trjExpensify

This comment has been minimized.

@github-project-automation github-project-automation bot moved this from First Cohort - HIGH to Done in [#whatsnext] #migrate Jan 14, 2025
@trjExpensify trjExpensify reopened this Jan 15, 2025
@trjExpensify trjExpensify moved this from Done to First Cohort - HIGH in [#whatsnext] #migrate Jan 15, 2025
@ishpaul777
Copy link
Contributor

@linhvovan29546 can you please move relevant part from your proposal here for me to review?

@linhvovan29546
Copy link
Contributor

linhvovan29546 commented Jan 16, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-16 00:30:54 UTC.

🚨 Edited by proposal-police: This proposal was edited at 2025-01-16 00:30:54 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Tooltip appeared on the global create disappear and did not appear back

What is the root cause of that problem?

The tooltip layout is retrieved using onLayout from cloneElement, which is triggered only once.

return React.cloneElement(children as React.ReactElement, {
onLayout: (e: LayoutChangeEventWithTarget) => {

When navigating back from another screen, getTooltipStyles re-renders to display the tooltip.
const {rootWrapperStyle, textStyle, pointerWrapperStyle, pointerStyle} = useMemo(
() =>
StyleUtils.getTooltipStyles({

However, getTooltipStyles re-renders before the screen translation is complete, causing elementAtTargetCenterX to retrieve the incorrect element (the overlay of the workspace switcher). As a result, isOverlappingAtTop returns true, which causes the tooltip to be displayed below the FAB button, making it invisible.

const isOverlappingAtTop: IsOverlappingAtTop = (tooltip, xOffset, yOffset, tooltipTargetWidth, tooltipTargetHeight) => {
if (typeof document.elementFromPoint !== 'function') {
return false;
}
// Use the x center position of the target to prevent wrong element returned by elementFromPoint
// in case the target has a border radius or is a multiline text.
const targetCenterX = xOffset + tooltipTargetWidth / 2;
const elementAtTargetCenterX = document.elementFromPoint(targetCenterX, yOffset);

rootWrapperTop = shouldShowBelow
? // We need to shift the tooltip down below the component. So shift the tooltip down (+) by...
yOffset + tooltipTargetHeight + POINTER_HEIGHT + manualShiftVertical

What changes do you think we should make in order to solve the problem?

To address this issue, we can use BoundsObserver to wrap the children of BaseEducationalTooltip. This approach, similar to the existing implementation here, ensures the layout is recalculated based on changes in the position of the children.
Exemple:

       const elementRef = useRef();
        const [isVisibleElement, setIsVisibleElement] = useState(false);

        const getBounds = (bounds: DOMRect): LayoutRectangle => {
        const targetElement = elementRef.current?._childNode;
        const elementAtPoint = document.elementFromPoint(bounds.x, bounds.y);
        if (elementAtPoint && 'contains' in elementAtPoint && targetElement && 'contains' in targetElement) {
            const isElementVisible =
                elementAtPoint instanceof HTMLElement &&
                (targetElement?.contains(elementAtPoint) || elementAtPoint?.contains(targetElement)); // We can update condition here, if we need other expected
            setIsVisibleElement(isElementVisible)
        }

        return bounds;
    };
...
<BoundsObserver
                        enabled={shouldRender}
                        onBoundsChange={(bounds) => {
                            updateTargetBounds(getBounds(bounds));
                        }}
                        ref={elementRef}
                    >
                        {React.cloneElement(children as React.ReactElement, {
                            onLayout: (e: LayoutChangeEventWithTarget) => {
                                if (!shouldMeasure) {
                                    setShouldMeasure(true);
                                }
                                // e.target is specific to native, use e.nativeEvent.target on web instead
                                const target = e.target || e.nativeEvent.target;
                                show.current = () => measureTooltipCoordinate(target, updateTargetBounds, showTooltip);
                            },
                        })}
                    </BoundsObserver>

We need isVisibleElement because we want to hide the tooltip when the content is not within the visible viewport.
Then we need to pass the isVisibleElement property to GenericTooltip.

            shouldRender={shouldRender && isVisibleElement}

For the detailed code, we can discuss it later in PR.

POC
Before After
OneCameraFinalVideo.12.mp4
OneCameraFinalVideo.11.mp4

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

No

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@linhvovan29546
Copy link
Contributor

linhvovan29546 commented Jan 16, 2025

@ishpaul777 I used the steps from this issue to reproduce the problem on mWeb Android and Web.

@linhvovan29546
Copy link
Contributor

Updated RCA after reviewing the details.

@ishpaul777
Copy link
Contributor

@linhvovan29546 can you please share a test branch, Proposal sounds good to me just want to run some tests before i recommend the proposal

@linhvovan29546
Copy link
Contributor

@linhvovan29546 can you please share a test branch, Proposal sounds good to me just want to run some tests before i recommend the proposal

Sure, the test branch is available here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
Status: First Cohort - HIGH
Development

No branches or pull requests

7 participants