aboutsummaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorAnastasia Smirnova <anasmi@utu.fi>2018-12-17 14:55:09 +0200
committerSun Zhe <31067185+ZheSun88@users.noreply.github.com>2018-12-17 14:55:09 +0200
commit12fe44d807404343c24caee5a1fc53ec031449c5 (patch)
treec4149362135d99e6c7f9b82233748cd662eb5e5f /server/src
parenta3fceafd4757c240c5871399eab008eb184ef531 (diff)
downloadvaadin-framework-12fe44d807404343c24caee5a1fc53ec031449c5.tar.gz
vaadin-framework-12fe44d807404343c24caee5a1fc53ec031449c5.zip
Improve VMenuBar click handling logic (#11356)
* 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 * Remove accidentally committed comment * Don't update the state on the getDelayMs call
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/ui/MenuBar.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/MenuBar.java b/server/src/main/java/com/vaadin/ui/MenuBar.java
index 7b2437e772..ce43802cc5 100644
--- a/server/src/main/java/com/vaadin/ui/MenuBar.java
+++ b/server/src/main/java/com/vaadin/ui/MenuBar.java
@@ -450,6 +450,28 @@ public class MenuBar extends AbstractComponent
getState().tabIndex = tabIndex;
}
+ /**
+ * Returns the delay before executing update logic inside
+ * {@link com.vaadin.client.ui.menubar.MenuBarConnector#updateFromUIDL(UIDL, ApplicationConnection)}
+ * after mouseDownEvent
+ *
+ * @since
+ */
+ public int getDelayMs() {
+ return getState(false).delayMs;
+ }
+
+ /**
+ * Set the delay before executing update logic inside
+ * {@link com.vaadin.client.ui.menubar.MenuBarConnector#updateFromUIDL(UIDL, ApplicationConnection)}
+ * after mouseDownEvent
+ *
+ * @since
+ */
+ public void setDelayMs(int delayMs) {
+ getState().delayMs = delayMs;
+ }
+
@Override
public void focus() {
// Overridden only to make public