flow
flow copied to clipboard
ClickEvent only works with primary mouse button
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
- Create a button and add it to a view
- Add a ClickListener via. addClickListener()
- 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