summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2013-07-03 16:33:50 +0300
committerHenri Sara <hesara@vaadin.com>2013-07-03 16:33:50 +0300
commitf7cc72df9b6fb54be95a02b9977e9df264037135 (patch)
tree819a7ba21f633f4809beacca723150071a79eb2d
parent478eeb51cd93812ee425801a42acc566a2fddf62 (diff)
downloadvaadin-framework-f7cc72df9b6fb54be95a02b9977e9df264037135.tar.gz
vaadin-framework-f7cc72df9b6fb54be95a02b9977e9df264037135.zip
Close only combobox on escape, not the window (#12163)
Change-Id: I356e115b5cd96ba0a598178a15215654f2fd16bb
-rw-r--r--client/src/com/vaadin/client/ui/VFilterSelect.java1
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/EscapeClosesComboboxNotWindow.java43
2 files changed, 44 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java
index e08fbf8ab6..a5c1e566ca 100644
--- a/client/src/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/com/vaadin/client/ui/VFilterSelect.java
@@ -1537,6 +1537,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
break;
case KeyCodes.KEY_ESCAPE:
reset();
+ DOM.eventPreventDefault(DOM.eventGetCurrentEvent());
event.stopPropagation();
break;
case KeyCodes.KEY_ENTER:
diff --git a/uitest/src/com/vaadin/tests/components/combobox/EscapeClosesComboboxNotWindow.java b/uitest/src/com/vaadin/tests/components/combobox/EscapeClosesComboboxNotWindow.java
new file mode 100644
index 0000000000..dcd19f6b2a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/EscapeClosesComboboxNotWindow.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+/**
+ * Ticket #12163: when a combo box popup is open in a subwindow, escape should
+ * only close it and not the window, also on Safari 6.
+ */
+public class EscapeClosesComboboxNotWindow extends UI {
+ final Window window = new Window("Window");
+
+ @Override
+ protected void init(VaadinRequest request) {
+ final VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ setContent(layout);
+
+ Button button = new Button("Click Me");
+ button.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ final FormLayout content = new FormLayout();
+ ComboBox cb = new ComboBox();
+ cb.addItem("foo");
+ cb.addItem("bar");
+ content.addComponent(cb);
+ window.setContent(content);
+ window.setCloseShortcut(KeyCode.ESCAPE);
+ UI.getCurrent().addWindow(window);
+ }
+ });
+ layout.addComponent(button);
+ }
+
+} \ No newline at end of file