]> source.dussan.org Git - vaadin-framework.git/commit
Improve VMenuBar click handling logic pr11356/r1
authorAnastasia Smirnova <anasmi@utu.fi>
Wed, 5 Dec 2018 07:39:27 +0000 (09:39 +0200)
committerAnastasia Smirnova <anasmi@utu.fi>
Wed, 5 Dec 2018 07:39:27 +0000 (09:39 +0200)
commit22cc85c76f28a762685204911ad66f95bda2d296
treeed893cac401b07bd8e6efbf228efca5874c831f7
parente56718a4f4c4aa9bf65b6227f17f7236935e46a4
Improve VMenuBar click handling logic

During `updateFromUIDL` inside MenuBarConnector we empty and re-instantiate the components of MenuBar. When we are modifying the Menubar from the BlurEventListener of another component, we ,by this, remove widgets, therefore clickEvent is not fired and the action of the MenuItem is not proceed as a result. (The BlurEvent is fired before the click event in the chain of events. )

To improve the situation, we catch onMouseDown event , which is fired before BlurEvent,by assigning mouseDown flag to true. Then if no click event has yet happened, we delay the execution of update inside `updateFromUIDL` by default 500 ms. Then if click event occurs, it proceeds normally. The time can be increased/decreased using setter.

There is no delay, if we are clicking on the MenuBar as usual or no Blur listener is set.

This change allows setting descriptions
client/src/main/java/com/vaadin/client/ui/VMenuBar.java
client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java
server/src/main/java/com/vaadin/ui/MenuBar.java
shared/src/main/java/com/vaadin/shared/ui/menubar/MenuBarState.java
uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarChangeFromEventListener.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarChangeFromEventListenerTest.java [new file with mode: 0644]