diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-09-15 11:22:32 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2014-09-15 19:58:46 +0000 |
commit | e8820f89e97b62b719351bf79a7740ed5e983c83 (patch) | |
tree | 280ec3ba9a8070103edf44810bc7fc6908822767 /client | |
parent | 861b57c196fa17f1488222125b9a89c38d6ad46d (diff) | |
download | vaadin-framework-e8820f89e97b62b719351bf79a7740ed5e983c83.tar.gz vaadin-framework-e8820f89e97b62b719351bf79a7740ed5e983c83.zip |
Prevent dispatching GridKeyEvents when target is not grid (#13334)
Change-Id: I2efd6d48502360d14d21456077d50b37fa8a4be6
Diffstat (limited to 'client')
4 files changed, 28 insertions, 23 deletions
diff --git a/client/src/com/vaadin/client/ui/grid/Grid.java b/client/src/com/vaadin/client/ui/grid/Grid.java index a667bfa8dd..5221284c3c 100644 --- a/client/src/com/vaadin/client/ui/grid/Grid.java +++ b/client/src/com/vaadin/client/ui/grid/Grid.java @@ -135,7 +135,6 @@ public class Grid<T> extends Composite implements private Grid<?> grid; protected Cell activeCell; - protected GridSection activeSection; private final Type<HANDLER> associatedType = new Type<HANDLER>( getBrowserEventType(), this); @@ -165,16 +164,25 @@ public class Grid<T> extends Composite implements @Override protected void dispatch(HANDLER handler) { - activeCell = grid.activeCellHandler.getActiveCell(); - activeSection = GridSection.FOOTER; - final RowContainer container = grid.activeCellHandler.container; - if (container == grid.escalator.getHeader()) { - activeSection = GridSection.HEADER; - } else if (container == grid.escalator.getBody()) { - activeSection = GridSection.BODY; + EventTarget target = getNativeEvent().getEventTarget(); + if (Element.is(target) + && Util.findWidget(Element.as(target), null) == grid) { + + activeCell = grid.activeCellHandler.getActiveCell(); + GridSection section = GridSection.FOOTER; + final RowContainer container = grid.activeCellHandler.container; + if (container == grid.escalator.getHeader()) { + section = GridSection.HEADER; + } else if (container == grid.escalator.getBody()) { + section = GridSection.BODY; + } + + doDispatch(handler, section); } } + protected abstract void doDispatch(HANDLER handler, GridSection seciton); + @Override public Type<HANDLER> getAssociatedType() { return associatedType; diff --git a/client/src/com/vaadin/client/ui/grid/events/GridKeyDownEvent.java b/client/src/com/vaadin/client/ui/grid/events/GridKeyDownEvent.java index 2fab683bb0..81ff0e0a19 100644 --- a/client/src/com/vaadin/client/ui/grid/events/GridKeyDownEvent.java +++ b/client/src/com/vaadin/client/ui/grid/events/GridKeyDownEvent.java @@ -33,11 +33,10 @@ public class GridKeyDownEvent extends AbstractGridKeyEvent<GridKeyDownHandler> { } @Override - protected void dispatch(GridKeyDownHandler handler) { - super.dispatch(handler); - if ((activeSection == GridSection.BODY && handler instanceof BodyKeyDownHandler) - || (activeSection == GridSection.HEADER && handler instanceof HeaderKeyDownHandler) - || (activeSection == GridSection.FOOTER && handler instanceof FooterKeyDownHandler)) { + protected void doDispatch(GridKeyDownHandler handler, GridSection section) { + if ((section == GridSection.BODY && handler instanceof BodyKeyDownHandler) + || (section == GridSection.HEADER && handler instanceof HeaderKeyDownHandler) + || (section == GridSection.FOOTER && handler instanceof FooterKeyDownHandler)) { handler.onKeyDown(this); } } diff --git a/client/src/com/vaadin/client/ui/grid/events/GridKeyPressEvent.java b/client/src/com/vaadin/client/ui/grid/events/GridKeyPressEvent.java index 112200b03a..9033344597 100644 --- a/client/src/com/vaadin/client/ui/grid/events/GridKeyPressEvent.java +++ b/client/src/com/vaadin/client/ui/grid/events/GridKeyPressEvent.java @@ -34,11 +34,10 @@ public class GridKeyPressEvent extends } @Override - protected void dispatch(GridKeyPressHandler handler) { - super.dispatch(handler); - if ((activeSection == GridSection.BODY && handler instanceof BodyKeyPressHandler) - || (activeSection == GridSection.HEADER && handler instanceof HeaderKeyPressHandler) - || (activeSection == GridSection.FOOTER && handler instanceof FooterKeyPressHandler)) { + protected void doDispatch(GridKeyPressHandler handler, GridSection section) { + if ((section == GridSection.BODY && handler instanceof BodyKeyPressHandler) + || (section == GridSection.HEADER && handler instanceof HeaderKeyPressHandler) + || (section == GridSection.FOOTER && handler instanceof FooterKeyPressHandler)) { handler.onKeyPress(this); } } diff --git a/client/src/com/vaadin/client/ui/grid/events/GridKeyUpEvent.java b/client/src/com/vaadin/client/ui/grid/events/GridKeyUpEvent.java index 9aa8ce7084..623f3d5ed8 100644 --- a/client/src/com/vaadin/client/ui/grid/events/GridKeyUpEvent.java +++ b/client/src/com/vaadin/client/ui/grid/events/GridKeyUpEvent.java @@ -33,11 +33,10 @@ public class GridKeyUpEvent extends AbstractGridKeyEvent<GridKeyUpHandler> { } @Override - protected void dispatch(GridKeyUpHandler handler) { - super.dispatch(handler); - if ((activeSection == GridSection.BODY && handler instanceof BodyKeyUpHandler) - || (activeSection == GridSection.HEADER && handler instanceof HeaderKeyUpHandler) - || (activeSection == GridSection.FOOTER && handler instanceof FooterKeyUpHandler)) { + protected void doDispatch(GridKeyUpHandler handler, GridSection section) { + if ((section == GridSection.BODY && handler instanceof BodyKeyUpHandler) + || (section == GridSection.HEADER && handler instanceof HeaderKeyUpHandler) + || (section == GridSection.FOOTER && handler instanceof FooterKeyUpHandler)) { handler.onKeyUp(this); } } |