accessible-menu
accessible-menu copied to clipboard
Bug: Menu toggled on right-click as well
Issue: Menu toggled on right-click as well
Description:
Currently, the menu is being toggled on both left and right mouse clicks. This is happening due to the use of pointerup
and pointerdown
events. These events listen to all mouse buttons (including the right-click) and are causing the menu to toggle unexpectedly.
Reference:
https://github.com/NickDJM/accessible-menu/blob/4.x/src/_baseMenu.js#L1432-L1452
https://codepen.io/nickdjm/pen/wvZvXvP
Steps to Reproduce:
- Open the menu.
- Observe the menu toggling on right-click.
Possible Solution:
- Use
click
event instead ofpointerup
. -
Recommended: Block the right-click within the
toggleToggle
function to avoid regressions:
https://stackoverflow.com/questions/21610592/pointer-events-method-of-checking-left-or-right-clickif (event.button === 2) { // do not toggle } else { // existing code to toggle menu }
Expected Behaviour:
- The menu should only toggle on a left-click (button 0).
- Right-click (button 2) should not trigger any toggle behavior.