aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-04-19 15:00:52 +0300
committerIlia Motornyi <elmot@vaadin.com>2018-04-19 15:00:52 +0300
commit07c6456da8f15d279340188dc86d7424cee36cd0 (patch)
treeabba54a5a0a2ab5b956bc568950ed414604c25d5 /client
parentf0bb6f4e35cb4ed3f01ea8cadb521e79d623870a (diff)
downloadvaadin-framework-07c6456da8f15d279340188dc86d7424cee36cd0.tar.gz
vaadin-framework-07c6456da8f15d279340188dc86d7424cee36cd0.zip
Fix for navigating in Grid using Tab
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/WidgetUtil.java4
-rw-r--r--client/src/main/java/com/vaadin/client/widgets/Escalator.java35
2 files changed, 38 insertions, 1 deletions
diff --git a/client/src/main/java/com/vaadin/client/WidgetUtil.java b/client/src/main/java/com/vaadin/client/WidgetUtil.java
index 58604fe005..2bbed2b92f 100644
--- a/client/src/main/java/com/vaadin/client/WidgetUtil.java
+++ b/client/src/main/java/com/vaadin/client/WidgetUtil.java
@@ -916,8 +916,10 @@ public class WidgetUtil {
EventListener eventListener = null;
while (eventListener == null && element != null) {
eventListener = Event.getEventListener(element);
- if (eventListener == null) {
+ if (eventListener == null
+ || !(eventListener instanceof Widget)) {
element = element.getParentElement();
+ eventListener = null;
}
}
if (eventListener instanceof Widget) {
diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java
index ced09dc705..785febc90c 100644
--- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java
@@ -30,6 +30,7 @@ import java.util.TreeMap;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.stream.Stream;
import com.google.gwt.animation.client.Animation;
import com.google.gwt.animation.client.AnimationScheduler;
@@ -53,9 +54,11 @@ import com.google.gwt.dom.client.TableCellElement;
import com.google.gwt.dom.client.TableRowElement;
import com.google.gwt.dom.client.TableSectionElement;
import com.google.gwt.dom.client.Touch;
+import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.logging.client.LogConfiguration;
import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RequiresResize;
import com.google.gwt.user.client.ui.RootPanel;
@@ -5823,6 +5826,38 @@ public class Escalator extends Widget
tableWrapper = DivElement.as(DOM.createDiv());
+ Event.sinkEvents(tableWrapper, Event.ONSCROLL | Event.KEYEVENTS);
+
+ Event.setEventListener(tableWrapper, event -> {
+ if (event.getKeyCode() != KeyCodes.KEY_TAB) {
+ return;
+ }
+
+ boolean browserScroll = tableWrapper.getScrollLeft() != 0
+ || tableWrapper.getScrollTop() != 0;
+ boolean keyEvent = event.getType().startsWith("key");
+
+ if (browserScroll || keyEvent) {
+
+ // Browser is scrolling our div automatically, reset
+ tableWrapper.setScrollLeft(0);
+ tableWrapper.setScrollTop(0);
+
+ Element focused = WidgetUtil.getFocusedElement();
+ Stream.of(header, body, footer).forEach(container -> {
+ Cell cell = container.getCell(focused);
+ if (cell == null) {
+ return;
+ }
+
+ scrollToColumn(cell.getColumn(), ScrollDestination.ANY, 0);
+ if (container == body) {
+ scrollToRow(cell.getRow(), ScrollDestination.ANY, 0);
+ }
+ });
+ }
+ });
+
root.appendChild(tableWrapper);
table = DOM.createTable();