From c9b1df6d5e9847ef4d5a6e810df22612ecbddca6 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Sun, 17 Apr 2016 18:29:08 +0300 Subject: Double check table focus in IE (#19676) Change-Id: I46d95e0b198dd4594e5c84dda9b6c462d4a7bf51 --- .../java/com/vaadin/client/ui/VScrollTable.java | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/src/main/java/com/vaadin/client/ui/VScrollTable.java b/client/src/main/java/com/vaadin/client/ui/VScrollTable.java index 5e5ae8a259..8bdafb9073 100644 --- a/client/src/main/java/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/main/java/com/vaadin/client/ui/VScrollTable.java @@ -569,7 +569,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // Cancel default keyboard events on a disabled Table // (prevents scrolling) event.preventDefault(); - } else if (hasFocus) { + } else if (hasFocus()) { // Key code in Firefox/onKeyPress is present only for // special keys, otherwise 0 is returned int keyCode = event.getKeyCode(); @@ -633,7 +633,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // Cancel default keyboard events on a disabled Table // (prevents scrolling) event.preventDefault(); - } else if (hasFocus) { + } else if (hasFocus()) { if (handleNavigation(event.getKeyCode(), event.getCtrlKey() || event.getMetaKey(), event.getShiftKey())) { navKeyDown = true; @@ -6780,7 +6780,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * focus only if not currently focused. */ protected void ensureFocus() { - if (!hasFocus) { + if (!hasFocus()) { scrollBodyPanel.setFocus(true); } @@ -7673,7 +7673,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // Set new focused row focusedRow = row; - if (hasFocus) { + if (hasFocus()) { ensureRowIsVisible(row); } @@ -7991,6 +7991,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets, @Override public void onBlur(BlurEvent event) { + onBlur(); + } + + private void onBlur() { hasFocus = false; navKeyDown = false; @@ -8367,4 +8371,19 @@ public class VScrollTable extends FlowPanel implements HasWidgets, public void setChildMeasurementHint(ChildMeasurementHint hint) { childMeasurementHint = hint; } + + private boolean hasFocus() { + if (hasFocus && BrowserInfo.get().isIE()) { + com.google.gwt.user.client.Element focusedElement = Util + .getIEFocusedElement(); + if (!getElement().isOrHasChild(focusedElement)) { + // Does not really have focus but a blur event has been lost + getLogger().warning( + "IE did not send a blur event, firing manually"); + onBlur(); + } + } + return hasFocus; + } + } -- cgit v1.2.3