[go: nahoru, domu]

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

[Bug]: Unable to close context menu in Windows & Linux due to PointerUp/MouseUp events swallowed after Menu.popup() #42563

Closed
3 tasks done
safris opened this issue Jun 18, 2024 · 1 comment
Labels
31-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/

Comments

@safris
Copy link
safris commented Jun 18, 2024

Preflight Checklist

Electron Version

31.0.0

What operating system are you using?

Windows

Operating System Version

Windows 11

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

No response

Expected Behavior

The provided GIST outlines the following use-cases:

Use-case (1) Works as expected on all platforms

  1. A user left-clicks (mouse down & up) on a HTML element.
  2. The element sends a message to the main process to show a context menu via Menu.popup().
  3. The user can interact with the shown Menu, or click outside of the menu to have the Menu disappear.

Actual Behavior

Use-case (2) Does not work as expected on Windows and Linux

  1. A user left-clicks (mouse down only) on a HTML element, and while holding the left mouse button, moves the mouse.
  2. At the moment of the "down" event, the main process shows a context menu via Menu.popup().
  3. As the user is moving the mouse with the left mouse button pressed, he can interact with the shown Menu.
  4. If the user thereafter releases the left mouse button outside of the Menu (i.e. not on a MenuItem):
    a. MacOS: The Menu disappears. This is the desired behavior.
    b. Windows & Linux: The Menu remains. Furthermore, the mouse "up" events are swallowed, so it is not possible to programmatically handle this edge case in the user code, thus making it impossible to hide the Menu upon the user releasing the left mouse button in this use-case.

Testcase Gist URL

https://gist.github.com/safris/ef48974847e38b91a7a302b13d47eb44

Additional Information

I speculate that the PointerUp/MouseUp events are swallowed when the Menu is shown, because the Menu is outside the WebContents. Propagating the PointerUp/MouseUp events to the WebContents while a Menu is shown seems to be a tall order.

A simpler approach could be to change the behavior of the context menu in Windows and Linux such that the context menu is automatically closed when a user releases the mouse click as is described in use-case (2).

@electron-issue-triage electron-issue-triage bot added 31-x-y has-repro-gist Issue can be reproduced with code at https://gist.github.com/ labels Jun 18, 2024
@safris
Copy link
Author
safris commented Jun 18, 2024

I believe I've created this bug in error. After investigating the default behavior of use-case (2) in Windows and Linux, I've realized that leaving the Menu shown after release of the mouse button is expected.

@safris safris closed this as completed Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
31-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/
Projects
Status: 🛠️ Fixed for Next Release
Development

No branches or pull requests

1 participant