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

fix: Right clicking with a custom context menu open should open another context menu #1526

Merged
merged 2 commits into from
Sep 20, 2023

Conversation

mattrunyon
Copy link
Collaborator

Fixes #1525

This was bothering me while working on element plugins which should have a panel w/ the custom context menu enabled. Tested on Chrome/Firefox on Linux

@mattrunyon mattrunyon requested a review from mofojed September 19, 2023 06:08
@mattrunyon mattrunyon self-assigned this Sep 19, 2023
@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Patch coverage: 53.84% and project coverage change: -0.01% ⚠️

Comparison is base (d796f83) 46.42% compared to head (9c546a5) 46.42%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1526      +/-   ##
==========================================
- Coverage   46.42%   46.42%   -0.01%     
==========================================
  Files         558      556       -2     
  Lines       35714    35711       -3     
  Branches     8916     8916              
==========================================
- Hits        16582    16580       -2     
+ Misses      19082    19081       -1     
  Partials       50       50              
Flag Coverage Δ
unit 46.42% <53.84%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...components/src/context-actions/ContextMenuRoot.tsx 68.75% <53.84%> (+2.79%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dsmmcken
Copy link
Contributor

dsmmcken commented Sep 19, 2023

Please suggest a basic test plan we can use to manually check this, because this has proven tricky. I can do the windows testing.

We need to test manually on the full matrix:

  • mac chrome
  • mac firefox
  • mac safari
  • linux chrome
  • linux firefox
  • windows chrome
  • windows edge
  • windows firefox

@mattrunyon
Copy link
Collaborator Author

Open a table. Right click on a row. Right click on another row. Both clicks should bring up the custom context menu.

Right click on different tabs in succession. Each should open the custom context menu. This is the e2e test I added to right click on the console tab then command history tab.

@dsmmcken
Copy link
Contributor

This introduces a new bug which prevents the native menu showing.

Right clicking on something that would be a native menu previously (like say you are trying to select text and copy text from a previously run command in the console) now it doesn't generate the native menu anymore, and further blocks all interactivity until another left click is performed. I assume we are generating like an empty menu with an overlay or something still when we shouldn't be.

Otherwise passes suggested manual testing on all Windows browsers.

@mattrunyon
Copy link
Collaborator Author

Good catch. It's actually an issue w/ just the console (native menu in other places like the maximize button or user settings button works fine).

We set/emit console clear and focus history as context actions, but they get filtered out by the util to turn them into menu items. Easy enough to add another check, but seems like a bug/unintended for those to be passed as context actions.

See https://github.com/deephaven/web-client-ui/blob/main/packages/console/src/Console.tsx#L878

@dsmmcken
Copy link
Contributor

Also noted same behaviour in console history panel's search field.

@mattrunyon
Copy link
Collaborator Author

Ok should be fixed. I took a quick look back, but looks like those actions never registered properly since the initial fork of DHC. They've always been filtered out. Not sure why they're registered as context menu items really other than to setup the shortcut I guess.

Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

Verified looks good on Mac as well

Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

Actually read Don's comments. Yeah the native menu still doesn't show up on the first right-click after showing our custom menu, unsure if that's something we should handle.
Also the context action items for clear/focus history were intended for keyboard shortcuts. Anything without a title is just a context action item that's triggered by keyboard and shouldn't appear in the menu.

@mattrunyon
Copy link
Collaborator Author

mattrunyon commented Sep 20, 2023

@mofojed Still good to merge this? I don't think we can handle showing the right-click after showing our custom menu. The event is getting re-emitted, but the browser doesn't seem to do anything with it. Probably because we listen for the event, but I'm guessing the native browser menu can only be triggered by trusted/user-interaction events, not our re-emit.

@dsmmcken
Copy link
Contributor

the native menu still doesn't show up on the first right-click after showing our custom menu
It does on Chrome/Windows.

This is okay on the Windows side.

@mattrunyon mattrunyon merged commit bd08e1f into deephaven:main Sep 20, 2023
@mattrunyon mattrunyon deleted the mattrunyon-1525 branch September 20, 2023 20:47
@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trying to open a context menu with a custom context menu already open does not work
3 participants