]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #5059 - Tabbing out of a PopupView closes it if hideOnMouseOut is true.
authorJonatan Kronqvist <jonatan.kronqvist@itmill.com>
Thu, 1 Jul 2010 05:18:19 +0000 (05:18 +0000)
committerJonatan Kronqvist <jonatan.kronqvist@itmill.com>
Thu, 1 Jul 2010 05:18:19 +0000 (05:18 +0000)
svn changeset:13983/svn branch:6.4

src/com/vaadin/terminal/gwt/client/ui/VPopupView.java
tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.html [new file with mode: 0644]
tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.java [new file with mode: 0644]

index 00c2ae5260a460759dc993e98a78ffc182ccd80c..a2f04e785c4e479f7593a60ac2ff4b8bebc780bd 100644 (file)
@@ -10,6 +10,7 @@ import java.util.Set;
 
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.KeyCodes;
 import com.google.gwt.event.logical.shared.CloseEvent;
 import com.google.gwt.event.logical.shared.CloseHandler;
 import com.google.gwt.user.client.DOM;
@@ -25,13 +26,13 @@ import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.Container;
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.RenderInformation.Size;
 import com.vaadin.terminal.gwt.client.RenderSpace;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
 import com.vaadin.terminal.gwt.client.VCaption;
 import com.vaadin.terminal.gwt.client.VCaptionWrapper;
 import com.vaadin.terminal.gwt.client.VTooltip;
-import com.vaadin.terminal.gwt.client.RenderInformation.Size;
 import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea;
 
 public class VPopupView extends HTML implements Container, Iterable<Widget> {
@@ -261,13 +262,22 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
             }
 
             if (!eventTargetsPopup && type == Event.ONMOUSEMOVE) {
-
                 if (hasHadMouseOver && hideOnMouseOut) {
                     hide();
                     return true;
                 }
             }
 
+            // Was the TAB key released outside of our popup?
+            if (!eventTargetsPopup && type == Event.ONKEYUP
+                    && event.getKeyCode() == KeyCodes.KEY_TAB) {
+                // Should we hide on focus out (mouse out)?
+                if (hideOnMouseOut) {
+                    hide();
+                    return true;
+                }
+            }
+
             return super.onEventPreview(event);
         }
 
@@ -350,7 +360,6 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
 
             popupComponentPaintable
                     .updateFromUIDL(uidl.getChildUIDL(0), client);
-
         }
 
         public void unregisterPaintables() {
diff --git a/tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.html b/tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.html
new file mode 100644 (file)
index 0000000..6c9d632
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>PopupViewShouldCloseOnTabOut</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">PopupViewShouldCloseOnTabOut</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.popupview.PopupViewShouldCloseOnTabOut?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewShouldCloseOnTabOut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupView[0]/domChild[0]</td>
+       <td>16,8</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>//div[4]/div/div/div/div[2]/div/input</td>
+       <td>34,8</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewShouldCloseOnTabOut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupView[0]/domChild[0]</td>
+       <td>19,3</td>
+</tr>
+<tr>
+       <td>pressSpecialKey</td>
+       <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewShouldCloseOnTabOut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupView[0]/domChild[0]</td>
+       <td>shift tab</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>PopupViewShouldBeClosed</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.java b/tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.java
new file mode 100644 (file)
index 0000000..7e91763
--- /dev/null
@@ -0,0 +1,53 @@
+package com.vaadin.tests.components.popupview;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.PopupView.Content;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+@SuppressWarnings("serial")
+public class PopupViewShouldCloseOnTabOut extends TestBase {
+
+    @Override
+    protected String getDescription() {
+        return "The PopupView should close when the user moves focus away from it using the TAB key.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 5059;
+    }
+
+    @Override
+    protected void setup() {
+        PopupView pv = new PopupView(new Content() {
+
+            public String getMinimizedValueAsHTML() {
+                return "<b>click me</b>";
+            }
+
+            public Component getPopupComponent() {
+                VerticalLayout vl = new VerticalLayout();
+                TextField field1 = new TextField();
+                field1.setValue("one");
+                field1.focus();
+                vl.addComponent(field1);
+                TextField field2 = new TextField();
+                field2.setValue("two");
+                vl.addComponent(field2);
+                vl.setWidth("600px");
+                return vl;
+            }
+        });
+        addComponent(pv);
+        TextField main = new TextField();
+        main.setValue("main");
+        addComponent(main);
+        TextField main2 = new TextField();
+        main2.setValue("main2");
+        addComponent(main2);
+    }
+
+}