flow icon indicating copy to clipboard operation
flow copied to clipboard

ClickEvent only works with primary mouse button

Open ImOlli opened this issue 1 year ago • 0 comments

Description

When adding a click listener to a button it only works with a left click. Middle clicks and other additional mouse buttons are not captured. This is due the clickevent only captures primary button clicks. For non primary button clicks the "auxclick" event is used.

Expected outcome

Since the API of the ClickEvent is providing a "button" i would expect the normal ClickEvent gets also fired when clicking with non primary buttons.

Minimal reproducible example

      Button button = new Button("Test");

      button.addClickListener(event -> {
         System.out.println("I am only executed when clicked with the left button");
      });

      button.getElement().addEventListener("click", event -> {
         System.out.println("I am also only executed when clicked with the left button");
      });

      button.getElement().addEventListener("auxclick", event -> {
         System.out.println("I am executed when click any other mouse button than the primary one");
      });

Steps to reproduce

  1. Create a button and add it to a view
  2. Add a ClickListener via. addClickListener()
  3. The ClickListener only gets executed when clicking with the primary button of the mouse.

Environment

Vaadin version(s): 23.1.0 OS: Windows 10

Browsers

Chrome

ImOlli avatar Jul 19 '22 08:07 ImOlli