Skip to content

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

Closed

Description

@IuliiaHerets

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

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 19, 2024
  2. melvin-bot commented on Oct 19, 2024

    @melvin-bot

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

  3. melvin-bot commented on Oct 19, 2024

    @melvin-bot

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

  4. melvin-bot commented on Oct 19, 2024

    @melvin-bot

    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.

  5. github-actions commented on Oct 19, 2024

    @github-actions
    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.
  6. bernhardoj commented on Oct 19, 2024

    @bernhardoj
    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]);
    
  7. bernhardoj commented on Oct 19, 2024

    @bernhardoj
    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
  8. MonilBhavsar commented on Oct 21, 2024

    @MonilBhavsar
    Contributor

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

  9. 49 remaining items

  10. melvin-bot commented on Dec 6, 2024

    @melvin-bot

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

  11. MitchExpensify commented on Dec 7, 2024

    @MitchExpensify
    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 👎

  12. MitchExpensify commented on Dec 7, 2024

    @MitchExpensify
    Contributor

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

  13. bernhardoj commented on Dec 8, 2024

    @bernhardoj
    Contributor

    Requested in ND.

  14. JmillsExpensify commented on Dec 9, 2024

    @JmillsExpensify
    Contributor

    Waiting on the payment summary.

  15. melvin-bot commented on Dec 11, 2024

    @melvin-bot

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

  16. MitchExpensify commented on Dec 11, 2024

    @MitchExpensify
    Contributor

    Payment summary:

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

  17. shubham1206agra commented on Dec 11, 2024

    @shubham1206agra
    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: 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 👎

  18. JmillsExpensify commented on Dec 11, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  19. shubham1206agra commented on Dec 12, 2024

    @shubham1206agra
    Contributor
  20. MitchExpensify commented on Dec 13, 2024

    @MitchExpensify
    Contributor

    Paid and contract ended @shubham1206agra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions