Vaadin 8: click listener fires multiple times

Hello,

knowing that there are already some similar threads, I’d like to ask whether there is an update regarding handling of multiple clicks on one element in a short sequence. In our application, we have following behavior:

  1. There is a simple click listener on a button which opens a modal window

When the user clicks on the button in a short sequence (double click, triple click), the window opens several times, although a modal window should block any interaction of the user with other UI elements. I assume that this is some race condition between the browser actions and the server side action - the server round trip might just take too long to block more click events from the button on the browser side.

  1. There is a click listener checking double clicks on grid items, and in the same grid a component column with a click listener on single clicks. When double-clicking on the component column, sometimes the double-click action is triggered, sometimes the single-click action - but multiple times, and few times even both. Most of the times, it works as expected.

The application runs with Vaadin 8.10.3.

Now the question: is there some other way to solve this than adding some check of time-between-events in the buttonClick/itemClick methods of the listeners? There are tens - hundreds of listeners in the application which all would need to be adapted. Or is this behavior just accepted for Vaadin applications as a consequence of the client-server function split and the delay caused by server roundtrips?

Thanks & Regards

Jochen

Hm, after some more digging, I can answer part of my own question:

For buttons, there is the setDisableOnclick method which allows disabling the button on a click - just need to re-enable the button in the buttonClick method. That prevents multiple firing on a short sequence of clicks.

For grids, there is some solution for single clicks: store the “open state” of the modal dialog opening on such a click in a Boolean member of the UI class handling the click, and open a new window only if that state is false. Reset the state in the onClose method of the opening window (needs to implement the CloseListener interface). Distinguishing single from double clicks would still only be possible by checking the time between clicks on the server side.

Any better solution is still welcome!

Regards
Jochen