From 9748ed6932022abfc044913eb706d11c0a2dfec5 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 12 Mar 2013 15:52:21 +0200 Subject: Fixed IE8 sub window focus issue after editing a RichTextArea #10776 Tests were merged to 7.0 in a previous commit. svn changeset:25458/svn branch:6.8 Change-Id: Ib4233f4d96311c76c104f1041f132377d357916d --- client/src/com/vaadin/client/ui/VWindow.java | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index bd9493c761..fd2a701334 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -22,6 +22,9 @@ import java.util.Comparator; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Position; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.FocusEvent; @@ -35,6 +38,7 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; @@ -423,6 +427,36 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, // Remove window from windowOrder to avoid references being left // hanging. windowOrder.remove(this); + + /* + * If the window has a RichTextArea and the RTA is focused at the time + * of hiding in IE8 only the window will have some problems returning + * the focus to the correct place. Curiously the focus will be returned + * correctly if clicking on the "close" button in the window header but + * closing the window from a button for example in the window will fail. + * Symptom described in #10776 + * + * The problematic part is that for the focus to be returned correctly + * an input element needs to be focused in the root panel. Focusing some + * other element apparently won't work. + */ + if (BrowserInfo.get().isIE8()) { + fixIE8FocusCaptureIssue(); + } + } + + private void fixIE8FocusCaptureIssue() { + Element e = DOM.createInputText(); + Style elemStyle = e.getStyle(); + elemStyle.setPosition(Position.ABSOLUTE); + elemStyle.setLeft(-10, Unit.PX); + elemStyle.setWidth(0, Unit.PX); + elemStyle.setHeight(0, Unit.PX); + + Element rootPanel = RootPanel.getBodyElement(); + rootPanel.appendChild(e); + e.focus(); + rootPanel.removeChild(e); } /** For internal use only. May be removed or replaced in the future. */ -- cgit v1.2.3