framework icon indicating copy to clipboard operation
framework copied to clipboard

Add consume functionality for Vaadin server events.

Open vaadin-bot opened this issue 10 years ago • 5 comments

Originally by bogdanudrescu


This would be a nice feature which is already present in all UI frameworks.

https://vaadin.com/forum/#!/thread/9669860/9926571


Imported from https://dev.vaadin.com/ issue #17811

vaadin-bot avatar May 12 '15 07:05 vaadin-bot

Hello there!

It looks like this issue hasn't progressed lately. There are so many issues that we just can't deal them all within a reasonable timeframe.

There are a couple of things you could help to get things rolling on this issue (this is an automated message, so expect that some of these are already in use):

  • Check if the issue is still valid for the latest version. There are dozens of duplicates in our issue tracker, so it is possible that the issue is already tackled. If it appears to be fixed, close the issue, otherwise report to the issue that it is still valid.
  • Provide more details how to reproduce the issue.
  • Explain why it is important to get this issue fixed and politely draw others attention to it e.g. via the forum or social media.
  • Add a reduced test case about the issue, so it is easier for somebody to start working on a solution.
  • Try fixing the issue yourself and create a pull request that contains the test case and/or a fix for it. Handling the pull requests is the top priority for the core team.
  • If the issue is clearly a bug, use the Warranty in your Vaadin subscription to raise its priority.

Thanks again for your contributions! Even though we haven't been able to get this issue fixed, we hope you to report your findings and enhancement ideas in the future too!

stale[bot] avatar Mar 20 '18 07:03 stale[bot]

I would like to correct George Forman's post in the linked thread. He is correct, it is not unusual to have event consumption. AWT, Swing, JavaFX DOM Events, and Qt are all examples which support this functionality.

See here for reference. The preventDefault method is comparable to Swing's consume method, but it does not act how George described it. preventDefault causes the default action to be canceled. For example, if a user right clicks on an element, the contextmenu event is invoked. If one were to call preventDefault, the actual context menu would not open. On the other hand, what George described is the functionality of stopPropagation. Say you have a list of 3 listeners. If listener 2 calls stopPropagation, listener 3 and any further listeners will not be invoked. For example, I am implementing this in a WIP extension. This is one of my methods:

private <T extends Event> void fireEvent(final Set<? extends Listener<T>> listeners, final T event) {
  for(final Listener<T> listener : listeners) {
    listener.dispatch(event);
    if(event.getDomEvent().shouldStopPropagation()) return;
  }
}

As for stopImmediatePropagation, this would be much harder to implement. GWT doesn't seem to have any sense of event phases, specifically bubbling.

oliveryasuna avatar Jul 12 '20 00:07 oliveryasuna

Yes please add this. I wanted to do something simple like make an accordion header editable when it is expanded, but there appears to be no way to prevent the accordion from closing when clicking into the editable header.

jonl-percsolutions-com avatar Feb 12 '21 01:02 jonl-percsolutions-com

This is nowadays possible in Vaadin 14+ with a workaround though. Also on that side there is some discussion about improving the API.

https://github.com/vaadin/flow/issues/1363

Adding this to Vaadin 8 would be rather worksome to do, and demand for the feature has not been high.

TatuLund avatar Feb 12 '21 08:02 TatuLund

@jonl-percsolutions-com Check out my extension: https://github.com/oliveryasuna/gimme-dom.

But I highly suggest you investigate Vaadin 10+. I only wrote this extension because it didn't make sense to upgrade at the time.

oliveryasuna avatar Feb 14 '21 05:02 oliveryasuna