aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMatti Tahvonen <matti@vaadin.com>2016-05-31 14:00:00 +0300
committerVaadin Code Review <review@vaadin.com>2016-08-30 16:27:09 +0000
commit7a6f250d89474849648ed2ee96a6bfb78c3b9ca8 (patch)
treead11d7bc0c3184ef4ed1c1985d0dd9f741077de9 /client
parent408253bc3f8bd3975f0525ce6832be214a3552e9 (diff)
downloadvaadin-framework-7a6f250d89474849648ed2ee96a6bfb78c3b9ca8.tar.gz
vaadin-framework-7a6f250d89474849648ed2ee96a6bfb78c3b9ca8.zip
Fire actions before removing menu from the DOM (#20080)
Change-Id: Ic1cd285c697a05d186d81935f632881e4cf561bf
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VMenuBar.java47
1 files changed, 21 insertions, 26 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VMenuBar.java b/client/src/main/java/com/vaadin/client/ui/VMenuBar.java
index b3825d2de5..e0cea1c837 100644
--- a/client/src/main/java/com/vaadin/client/ui/VMenuBar.java
+++ b/client/src/main/java/com/vaadin/client/ui/VMenuBar.java
@@ -21,7 +21,6 @@ import java.util.List;
import java.util.Queue;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
@@ -437,16 +436,16 @@ public class VMenuBar extends SimpleFocusablePanel implements
*/
public void itemClick(CustomMenuItem item) {
if (item.getCommand() != null) {
- setSelected(null);
-
- if (visibleChildMenu != null) {
- visibleChildMenu.hideChildren();
+ try {
+ item.getCommand().execute();
+ } finally {
+ setSelected(null);
+ if (visibleChildMenu != null) {
+ visibleChildMenu.hideChildren();
+ }
+ hideParents(true);
+ menuVisible = false;
}
-
- hideParents(true);
- menuVisible = false;
- Scheduler.get().scheduleDeferred(item.getCommand());
-
} else {
if (item.getSubMenu() != null
&& item.getSubMenu() != visibleChildMenu) {
@@ -1523,23 +1522,19 @@ public class VMenuBar extends SimpleFocusablePanel implements
// selection there
openMenuAndFocusFirstIfPossible(getSelected());
} else {
- final Command command = getSelected().getCommand();
-
- setSelected(null);
- hideParents(true);
-
- // #17076 keyboard selected menuitem without children: do
- // not leave menu to visible ("hover open") mode
- menuVisible = false;
-
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- if (command != null) {
- command.execute();
- }
+ try {
+ final Command command = getSelected().getCommand();
+ if (command != null) {
+ command.execute();
}
- });
+ } finally {
+ setSelected(null);
+ hideParents(true);
+
+ // #17076 keyboard selected menuitem without children: do
+ // not leave menu to visible ("hover open") mode
+ menuVisible = false;
+ }
}
}