accessible-menu icon indicating copy to clipboard operation
accessible-menu copied to clipboard

Bug: Menu toggled on right-click as well

Open nileshbhagwat opened this issue 4 months ago • 7 comments

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 image

Steps to Reproduce:

  1. Open the menu.
  2. Observe the menu toggling on right-click.

Possible Solution:

  1. Use click event instead of pointerup.
  2. Recommended: Block the right-click within the toggleToggle function to avoid regressions:
    if (event.button === 2) {
        // do not toggle
    } else {
        // existing code to toggle menu
    }
    
    https://stackoverflow.com/questions/21610592/pointer-events-method-of-checking-left-or-right-click

Expected Behaviour:

  • The menu should only toggle on a left-click (button 0).
  • Right-click (button 2) should not trigger any toggle behavior.

nileshbhagwat avatar Oct 22 '24 10:10 nileshbhagwat