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

[HOLD for payment 2024-12-03] [$250] Composer - Emoji picker does not open when opening context menu and clicking emoji picker #51114

Closed
2 of 8 tasks
IuliiaHerets opened this issue Oct 19, 2024 · 45 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Oct 19, 2024

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.51-1
Reproducible in staging?: Y
Reproducible in production?: N
Issue was found when executing this PR: #50974
Email or phone of affected tester (no customers): applausetester+kh081006@applause.expensifail.com
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Open report.
  3. Send a message.
  4. Right click on the message.
  5. Click on the emoji picker in the composer.
  6. Right click on the message.
  7. Click on the emoji picker in the composer.

Expected Result:

Emoji picker will open.

Actual Result:

Emoji picker does not open.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6639177_1729286544151.20241019_051934.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021848230166570821208
  • Upwork Job ID: 1848230166570821208
  • Last Price Increase: 2024-10-28
  • Automatic offers:
    • shubham1206agra | Reviewer | 104727454
Issue OwnerCurrent Issue Owner: @MitchExpensify
@IuliiaHerets IuliiaHerets added DeployBlockerCash This issue or pull request should block deployment Bug Something is broken. Auto assigns a BugZero manager. labels Oct 19, 2024
Copy link

melvin-bot bot commented Oct 19, 2024

Triggered auto assignment to @MonilBhavsar (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Oct 19, 2024

💬 A slack conversation has been started in #expensify-open-source

Copy link

melvin-bot bot commented Oct 19, 2024

Triggered auto assignment to @MitchExpensify (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.

@melvin-bot melvin-bot bot added the Daily KSv2 label Oct 19, 2024
@github-actions github-actions bot added the Hourly KSv2 label Oct 19, 2024
@melvin-bot melvin-bot bot removed the Hourly KSv2 label Oct 19, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@bernhardoj
Copy link
Contributor

Proposal

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

Emoji picker doesn't show when we open emoji picker first, and then context menu, and then emoji picker button again.

What is the root cause of that problem?

When we open the emoji picker and then context menu, you can notice that the emoji picker button tooltip won't show. It's because isPopoverRelatedToTooltipOpen is not updated properly.

const isPopoverRelatedToTooltipOpen = useMemo(() => {
// eslint-disable-next-line @typescript-eslint/dot-notation
const tooltipNode = (tooltipRef.current?.['_childNode'] as Node | undefined) ?? null;
if (
isOpen &&
popover?.anchorRef?.current &&
tooltipNode &&
((popover.anchorRef.current instanceof Node && tooltipNode.contains(popover.anchorRef.current)) || tooltipNode === popover.anchorRef.current)
) {
return true;
}
return false;
}, [isOpen, popover]);
if (!shouldRender || isPopoverRelatedToTooltipOpen) {
return children;
}
return (
<BaseTooltip

isPopoverRelatedToTooltipOpen tells whether the tooltip element contains/is the same as the visible/active popover anchor. It's to prevent the tooltip of a button that shows the popover from showing while the popover is active. For example, if we open the emoji picker, the emoji picker button tooltip won't show.

So, currently, isPopoverRelatedToTooltipOpen for the emoji picker button is true. When we press the emoji picker button again, isPopoverRelatedToTooltipOpen will update from true to false (because the context menu is closed) which will re-render the emoji picker button, so the press/click event is never received.

if (!shouldRender || isPopoverRelatedToTooltipOpen) {
return children;
}
return (
<BaseTooltip
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={tooltipRef}
>
{children}
</BaseTooltip>

isPopoverRelatedToTooltipOpen doesn't update properly because it depends on a (active popover) ref (other than the isOpen state).

When we open an emoji picker and then the context menu, the isOpen state of the popover stays true, so the memo is not recalculated.

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

We need to create a new state to store the active popover to re-trigger the isPopoverRelatedToTooltipOpen memo. Because we only want to get the anchor ref, we can store the anchor ref only to the state instead of the whole popover element.

((popover.anchorRef.current instanceof Node && tooltipNode.contains(popover.anchorRef.current)) || tooltipNode === popover.anchorRef.current)

First, in PopoverProvider, create the new state.

function PopoverContextProvider(props: PopoverContextProps) {
const [isOpen, setIsOpen] = useState(false);
const activePopoverRef = useRef<AnchorRef | null>(null);

const [activePopoverAnchor, setActivePopoverAnchor] = useState(null);

Then, set the popover anchor state when a popover is shown.

const onOpen = useCallback(
(popoverParams: AnchorRef) => {
if (activePopoverRef.current && activePopoverRef.current.ref !== popoverParams?.ref) {
closePopover(activePopoverRef.current.anchorRef);
}
activePopoverRef.current = popoverParams;
setIsOpen(true);

setActivePopoverAnchor(popoverParams.anchorRef.current);

Clear it here too.

const closePopover = useCallback((anchorRef?: RefObject<View | HTMLElement | Text>): boolean => {
if (!activePopoverRef.current || (anchorRef && anchorRef !== activePopoverRef.current.anchorRef)) {
return false;
}
activePopoverRef.current.close();
activePopoverRef.current = null;
setIsOpen(false);

Then, pass the state to the context value,

const contextValue = useMemo(
() => ({
onOpen,
close: closePopover,
popover: activePopoverRef.current,
isOpen,
}),
[onOpen, closePopover, isOpen],
);

const contextValue = useMemo(
    () => ({
        onOpen,
        close: closePopover,
        popover: activePopoverRef.current,
        popoverAnchor: activePopoverAnchor,
        isOpen,
    }),
    [onOpen, closePopover, isOpen, activePopoverAnchor],
);

Last, replace all popover.anchorRef.current to popoverAnchor.

const {isOpen, popover} = useContext(PopoverContext);
const tooltipRef = useRef<BoundsObserver>(null);
const isPopoverRelatedToTooltipOpen = useMemo(() => {
// eslint-disable-next-line @typescript-eslint/dot-notation
const tooltipNode = (tooltipRef.current?.['_childNode'] as Node | undefined) ?? null;
if (
isOpen &&
popover?.anchorRef?.current &&
tooltipNode &&
((popover.anchorRef.current instanceof Node && tooltipNode.contains(popover.anchorRef.current)) || tooltipNode === popover.anchorRef.current)
) {
return true;
}
return false;
}, [isOpen, popover]);

const {isOpen, popoverAnchor} = useContext(PopoverContext);

const isPopoverRelatedToTooltipOpen = useMemo(() => {
    // eslint-disable-next-line @typescript-eslint/dot-notation
    const tooltipNode = (tooltipRef.current?.['_childNode'] as Node | undefined) ?? null;

    if (
        isOpen &&
        popoverAnchor &&
        tooltipNode &&
        ((popoverAnchor instanceof Node && tooltipNode.contains(popoverAnchor)) || tooltipNode === popoverAnchor)
    ) {
        return true;
    }

    return false;
}, [isOpen, popoverAnchor]);

@bernhardoj
Copy link
Contributor

This doesn't happen in prod because, in prod, you can't open the chat context menu while an emoji picker is visible. But this issue happens in prod if you open the LHN context menu. So, I posted my proposal above because it's an existing issue.

web.mp4

@MonilBhavsar
Copy link
Contributor

@bernhardoj looks like it is coming from regression from this PR #50974?

@bernhardoj
Copy link
Contributor

It happens after #50974, yes, but it's an existing issue which I explained in my comment above.

@MonilBhavsar
Copy link
Contributor

Thanks for the context! So this is not really a blocker

@MonilBhavsar MonilBhavsar added External Added to denote the issue can be worked on by a contributor and removed DeployBlockerCash This issue or pull request should block deployment labels Oct 21, 2024
@melvin-bot melvin-bot bot changed the title Composer - Emoji picker does not open when opening context menu and clicking emoji picker [$250] Composer - Emoji picker does not open when opening context menu and clicking emoji picker Oct 21, 2024
Copy link

melvin-bot bot commented Oct 21, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 21, 2024
Copy link

melvin-bot bot commented Oct 21, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @shubham1206agra (External)

Copy link

melvin-bot bot commented Oct 24, 2024

@MonilBhavsar, @MitchExpensify, @shubham1206agra Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Oct 24, 2024
@MitchExpensify
Copy link
Contributor

@shubham1206agra, how does @bernhardoj 's proposal look to you?

@shubham1206agra
Copy link
Contributor

So, currently, isPopoverRelatedToTooltipOpen for the emoji picker button is true.

@bernhardoj Can you tell me why is it true?

@melvin-bot melvin-bot bot added the Weekly KSv2 label Nov 4, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @shubham1206agra

@MitchExpensify
Copy link
Contributor

How is the PR looking @shubham1206agra ?

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 26, 2024
@melvin-bot melvin-bot bot changed the title [$250] Composer - Emoji picker does not open when opening context menu and clicking emoji picker [HOLD for payment 2024-12-03] [$250] Composer - Emoji picker does not open when opening context menu and clicking emoji picker Nov 26, 2024
Copy link

melvin-bot bot commented Nov 26, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 26, 2024
Copy link

melvin-bot bot commented Nov 26, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.66-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-12-03. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Nov 26, 2024

@shubham1206agra @MitchExpensify @shubham1206agra The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Dec 3, 2024
Copy link

melvin-bot bot commented Dec 6, 2024

@MonilBhavsar, @MitchExpensify, @bernhardoj, @shubham1206agra Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@MitchExpensify
Copy link
Contributor

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

    Link to comment:

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

    Link to discussion:

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

Regression Test Proposal Template
  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Precondition:

Test:

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot removed the Overdue label Dec 7, 2024
@MitchExpensify
Copy link
Contributor

MitchExpensify commented Dec 7, 2024

@shubham1206agra please complete the BZ steps above and accept this offer: https://www.upwork.com/nx/wm/offer/105238174

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

Waiting on the payment summary.

@melvin-bot melvin-bot bot added the Overdue label Dec 10, 2024
Copy link

melvin-bot bot commented Dec 11, 2024

@MonilBhavsar, @MitchExpensify, @bernhardoj, @shubham1206agra Whoops! This issue is 2 days overdue. Let's get this updated quick!

@MitchExpensify
Copy link
Contributor

Payment summary:

Reminder about the BZ steps, @shubham1206agra : #51114 (comment)

@shubham1206agra
Copy link
Contributor

shubham1206agra commented Dec 11, 2024

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

    Link to comment: Fix when emoji picker is opened, right-clicking on message opens and closes context menu #50974 (comment)

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

    Link to discussion: Not Required

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Precondition:

  • Test should only be on large screen view (Web/Desktop)

Test:

  1. Open App
  2. Open any report.
  3. Send a message.
  4. Right-click on the message.
  5. Click on the emoji picker in the composer.
  6. Right-click on the message.
  7. Click on the emoji picker in the composer.
  8. Observe that the popover is opening correctly.

Do we agree 👍 or 👎

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

@shubham1206agra
Copy link
Contributor

@MitchExpensify
Copy link
Contributor

Paid and contract ended @shubham1206agra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

6 participants