From 8f886a34195422d5bb682765214cff455feb9eb3 Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Thu, 1 Jul 2010 05:18:19 +0000 Subject: [PATCH] Fix for #5059 - Tabbing out of a PopupView closes it if hideOnMouseOut is true. svn changeset:13983/svn branch:6.4 --- .../terminal/gwt/client/ui/VPopupView.java | 15 ++++-- .../PopupViewShouldCloseOnTabOut.html | 47 ++++++++++++++++ .../PopupViewShouldCloseOnTabOut.java | 53 +++++++++++++++++++ 3 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.html create mode 100644 tests/src/com/vaadin/tests/components/popupview/PopupViewShouldCloseOnTabOut.java 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 { @@ -261,13 +262,22 @@ public class VPopupView extends HTML implements Container, Iterable { } 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 { 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 @@ + + + + + + +PopupViewShouldCloseOnTabOut + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PopupViewShouldCloseOnTabOut
open/run/com.vaadin.tests.components.popupview.PopupViewShouldCloseOnTabOut?restartApplication
mouseClickvaadin=runcomvaadintestscomponentspopupviewPopupViewShouldCloseOnTabOut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupView[0]/domChild[0]16,8
mouseClick//div[4]/div/div/div/div[2]/div/input34,8
mouseClickvaadin=runcomvaadintestscomponentspopupviewPopupViewShouldCloseOnTabOut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupView[0]/domChild[0]19,3
pressSpecialKeyvaadin=runcomvaadintestscomponentspopupviewPopupViewShouldCloseOnTabOut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupView[0]/domChild[0]shift tab
screenCapturePopupViewShouldBeClosed
+ + 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 "click me"; + } + + 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); + } + +} -- 2.39.5