Open vaadin-bot opened 9 years ago
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):
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!
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.
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.
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.
@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.
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