]> source.dussan.org Git - vaadin-framework.git/commitdiff
#4285 Additional fix so IE does not force focus back to field when focusing another...
authorArtur Signell <artur.signell@itmill.com>
Mon, 7 Mar 2011 09:31:26 +0000 (09:31 +0000)
committerArtur Signell <artur.signell@itmill.com>
Mon, 7 Mar 2011 09:31:26 +0000 (09:31 +0000)
svn changeset:17633/svn branch:6.5

src/com/vaadin/terminal/gwt/client/Util.java
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

index 00519a5c15d5c1e50165f1ee3f5c9d9f6dd63d70..f10755f2882211e489127ef66fd9c1eb5faae5fd 100644 (file)
@@ -1096,4 +1096,18 @@ public class Util {
 
     }
 
+    /**
+     * Gets the currently focused element for Internet Explorer.
+     * 
+     * @return The currently focused element
+     */
+    public native static Element getIEFocusedElement()
+    /*-{
+       if ($wnd.document.activeElement) {
+           return $wnd.document.activeElement;
+       }
+       
+       return null;
+     }-*/
+    ;
 }
index 66adc39d637588f61781f0f7d352ecdcc62c4e8d..ce96e44eb6e1a736b52a954303ae994e771faba4 100644 (file)
@@ -48,6 +48,7 @@ import com.vaadin.terminal.gwt.client.Focusable;
 import com.vaadin.terminal.gwt.client.Paintable;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
+import com.vaadin.terminal.gwt.client.VConsole;
 import com.vaadin.terminal.gwt.client.VTooltip;
 
 /**
@@ -854,7 +855,6 @@ public class VFilterSelect extends Composite implements Paintable, Field,
         popupOpener.addClickHandler(this);
     }
 
-
     /**
      * Does the Select have more pages?
      * 
@@ -1418,7 +1418,6 @@ public class VFilterSelect extends Composite implements Paintable, Field,
         return w;
     }-*/;
 
-
     /**
      * A flag which prevents a focus event from taking place
      */
@@ -1470,19 +1469,29 @@ public class VFilterSelect extends Composite implements Paintable, Field,
 
     public void onBlur(BlurEvent event) {
 
-        /*
-         * Sometimes we need in IE to manually disable a blur event which gets
-         * triggered by a mouseclick which we cannot prevent. In this cases we
-         * refocus the textfield and ignore the blur event.
-         */
         if (BrowserInfo.get().isIE() && preventNextBlurEventInIE) {
+            /*
+             * Clicking in the suggestion popup or on the popup button in IE
+             * causes a blur event to be sent for the field. In other browsers
+             * this is prevented by canceling/preventing default behavior for
+             * the focus event, in IE we handle it here by refocusing the text
+             * field and ignoring the resulting focus event for the textfield
+             * (in onFocus).
+             */
             preventNextBlurEventInIE = false;
 
-            // Move the focus back to the textfield without triggering a
-            // onFocus-event
-            iePreventNextFocus = true;
-            tb.setFocus(true);
-            return;
+            Element focusedElement = Util.getIEFocusedElement();
+            if (getElement().isOrHasChild(focusedElement)
+                    || suggestionPopup.getElement()
+                            .isOrHasChild(focusedElement)) {
+
+                // IF the suggestion popup or another part of the VFilterSelect
+                // was focused, move the focus back to the textfield and prevent
+                // the triggered focus event (in onFocus).
+                iePreventNextFocus = true;
+                tb.setFocus(true);
+                return;
+            }
         }
 
         focused = false;