diff options
author | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2010-07-01 05:18:19 +0000 |
---|---|---|
committer | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2010-07-01 05:18:19 +0000 |
commit | 8f886a34195422d5bb682765214cff455feb9eb3 (patch) | |
tree | cbc8a5071e4bfb462d36778533e3a49bd64a20e7 | |
parent | d31283d0afe8cd23325accf3f26c49a17d3c54a4 (diff) | |
download | vaadin-framework-8f886a34195422d5bb682765214cff455feb9eb3.tar.gz vaadin-framework-8f886a34195422d5bb682765214cff455feb9eb3.zip |
Fix for #5059 - Tabbing out of a PopupView closes it if hideOnMouseOut is true.
svn changeset:13983/svn branch:6.4
3 files changed, 112 insertions, 3 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java index 00c2ae5260..a2f04e785c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupView.java @@ -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 index 0000000000..6c9d632ed9 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.html @@ -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 index 0000000000..7e917630c8 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.java @@ -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); + } + +} |