Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.46k stars 2.81k forks source link

[$250] Chat - When emoji picker is opened, right-clicking on message opens and closes context menu #50314

Open IuliiaHerets opened 3 days ago

IuliiaHerets commented 3 days ago

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.45-2 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+pso@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to any report.
  3. Send a message.
  4. Open emoji picker.
  5. Right click on the message.

Expected Result:

Context menu will open.

Actual Result:

Context menu opens then closes.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/4c5a56fb-b356-4233-9cdb-ddf04cdb6f33

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021843403179458469285
  • Upwork Job ID: 1843403179458469285
  • Last Price Increase: 2024-10-07
Issue OwnerCurrent Issue Owner: @dukenv0307
melvin-bot[bot] commented 3 days ago

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

IuliiaHerets commented 3 days ago

@RachCHopkins FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

ChavdaSachin commented 3 days ago

Proposal

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

When emoji picker is opened, right-clicking on message opens and closes context menu.

What is the root cause of that problem?

We display EmojiPicker without overlay. https://github.com/Expensify/App/blob/6d8e739f7b1c286ae65565a6689b27b5983fe48a/src/components/EmojiPicker/EmojiPicker.tsx#L210

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

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.

bernhardoj commented 2 days ago

Proposal

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

Right clicking the message when an emoji picker is opened will close the context menu again.

What is the root cause of that problem?

When we right click on a message while the emoji picker is open, it will close the emoji picker before open the context menu. https://github.com/Expensify/App/blob/6d8e739f7b1c286ae65565a6689b27b5983fe48a/src/components/PopoverWithoutOverlay/index.tsx#L52-L56 https://github.com/Expensify/App/blob/6d8e739f7b1c286ae65565a6689b27b5983fe48a/src/components/PopoverProvider/index.tsx#L105-L109

When the emoji picker hide, it will call the popover context close function, passing the emoji picker anchor ref. https://github.com/Expensify/App/blob/6d8e739f7b1c286ae65565a6689b27b5983fe48a/src/components/PopoverWithoutOverlay/index.tsx#L58-L62

At this point, the anchor ref is null. It's important to pass the anchor ref to ignore the close call if the active popover anchor ref (context menu anchor ref) is different from the passed anchor ref (emoji picker anchor ref). https://github.com/Expensify/App/blob/6d8e739f7b1c286ae65565a6689b27b5983fe48a/src/components/PopoverProvider/index.tsx#L25-L30

But because the emoji picker anchor ref is null, the logic is passed and activePopoverRef.current.close() is executed which closes the context menu.

The anchor ref is null because we set it to null when closing the emoji picker. https://github.com/Expensify/App/blob/7981265dc14bc9cb99b512baddbb027446568fcf/src/components/EmojiPicker/EmojiPicker.tsx#L121-L123

However, the real issue here is that, the anchor ref shouldn't be null at all. It should be a ref object, {current: object | null}. This happens after https://github.com/Expensify/App/pull/37641, a TS migration, specifically updating the getEmojiPopoverAnchor code.

https://github.com/Expensify/App/blob/7981265dc14bc9cb99b512baddbb027446568fcf/src/components/EmojiPicker/EmojiPicker.tsx#L52-L59

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

We need to revert the getEmojiPopoverAnchor changes to

const getEmojiPopoverAnchor = useCallback(() => emojiPopoverAnchorRef.current ?? emojiPopoverAnchorRef as EmojiPopoverAnchor, []);
RachCHopkins commented 2 days ago

Yes, can replicate this.

melvin-bot[bot] commented 2 days ago

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

melvin-bot[bot] commented 2 days ago

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

dukenv0307 commented 1 day ago

@bernhardoj's proposal LGTM and tests well

🎀👀🎀 C+ reviewed

melvin-bot[bot] commented 1 day ago

Triggered auto assignment to @stitesExpensify, see https://stackoverflow.com/c/expensify/questions/7972 for more details.