summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-12-19 17:15:12 +0200
committerVaadin Code Review <review@vaadin.com>2014-12-29 11:09:17 +0000
commitb89213ee880dd1197bc7696f6f5a1919c0ff02c1 (patch)
treef5d3bfe6c4848be787f7d88b6fd32f80d4e0746c
parent93e83ab8fa7b0b692c91bebf35c135886354cf5e (diff)
downloadvaadin-framework-b89213ee880dd1197bc7696f6f5a1919c0ff02c1.tar.gz
vaadin-framework-b89213ee880dd1197bc7696f6f5a1919c0ff02c1.zip
Prevent key events without key code from triggering actions (#11029)
Seemingly not possible to auto-test reliably Change-Id: Idb492465323d91279caf170646590a54847b9414
-rw-r--r--client/src/com/vaadin/client/ui/ShortcutActionHandler.java3
-rw-r--r--uitest/src/com/vaadin/tests/actions/ActionsWithoutKeyCode.java39
2 files changed, 42 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java
index 9e9279267d..a9d5f0731a 100644
--- a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java
+++ b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java
@@ -123,6 +123,9 @@ public class ShortcutActionHandler {
final int modifiers = KeyboardListenerCollection
.getKeyboardModifiers(event);
final char keyCode = (char) DOM.eventGetKeyCode(event);
+ if (keyCode == 0) {
+ return;
+ }
final ShortcutKeyCombination kc = new ShortcutKeyCombination(keyCode,
modifiers);
final Iterator<ShortcutAction> it = actions.iterator();
diff --git a/uitest/src/com/vaadin/tests/actions/ActionsWithoutKeyCode.java b/uitest/src/com/vaadin/tests/actions/ActionsWithoutKeyCode.java
new file mode 100644
index 0000000000..e94a4b1ade
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/actions/ActionsWithoutKeyCode.java
@@ -0,0 +1,39 @@
+package com.vaadin.tests.actions;
+
+import com.vaadin.event.Action;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.TextField;
+
+@SuppressWarnings("serial")
+public class ActionsWithoutKeyCode extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TextField tf = new TextField();
+ tf.setWidth("100%");
+ tf.setInputPrompt("Enter text with å,ä or ä or press windows key while textfield is focused");
+ addComponent(tf);
+
+ addActionHandler(new Action.Handler() {
+
+ private Action[] actions;
+ {
+ actions = new Action[] { new Action("test1") };
+ }
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ return actions;
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ log("action " + action.getCaption() + " triggered by "
+ + sender.getClass().getSimpleName() + " on "
+ + target.getClass().getSimpleName());
+ }
+ });
+ }
+
+} \ No newline at end of file