diff options
author | Yuriy Artamonov <jreznot@users.noreply.github.com> | 2019-03-29 12:58:05 +0400 |
---|---|---|
committer | Anastasia Smirnova <anasmi@utu.fi> | 2019-03-29 10:58:05 +0200 |
commit | 47711930328c045fa97aa77054dcf2db05d5fe28 (patch) | |
tree | ad9fe37badc06aadccb940eba9448b201b443f42 /compatibility-client | |
parent | 339499164cfddaa9bd45b588c451f18374ad3ceb (diff) | |
download | vaadin-framework-47711930328c045fa97aa77054dcf2db05d5fe28.tar.gz vaadin-framework-47711930328c045fa97aa77054dcf2db05d5fe28.zip |
Support Firefox 65+ key down event behavior (#11503)
Fixes #11502
Diffstat (limited to 'compatibility-client')
4 files changed, 29 insertions, 14 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java index 6789e43fe5..323897c988 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java @@ -212,11 +212,11 @@ public class VCalendarPanel extends FocusableFlexTable implements Roles.getGridRole().set(getElement()); /* - * Firefox auto-repeat works correctly only if we use a key press + * Firefox prior to v65 auto-repeat works correctly only if we use a key press * handler, other browsers handle it correctly when using a key down * handler */ - if (BrowserInfo.get().isGecko()) { + if (BrowserInfo.get().isGecko() && BrowserInfo.get().getGeckoVersion() < 65) { addKeyPressHandler(this); } else { addKeyDownHandler(this); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java index fcf9c75590..088c8a2bd6 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java @@ -568,10 +568,10 @@ public class VScrollTable extends FlowPanel @Override public void onKeyPress(KeyPressEvent keyPressEvent) { - // This is used for Firefox only, since Firefox auto-repeat + // This is used for Firefox (prior to v65) only, since Firefox auto-repeat // works correctly only if we use a key press handler, other // browsers handle it correctly when using a key down handler - if (!BrowserInfo.get().isGecko()) { + if (!useOldGeckoNavigation()) { return; } @@ -635,8 +635,8 @@ public class VScrollTable extends FlowPanel @Override public void onKeyDown(KeyDownEvent keyDownEvent) { NativeEvent event = keyDownEvent.getNativeEvent(); - // This is not used for Firefox - if (BrowserInfo.get().isGecko()) { + // This is not used for Firefox after v65 + if (useOldGeckoNavigation()) { return; } @@ -840,11 +840,11 @@ public class VScrollTable extends FlowPanel scrollBodyPanel.addScrollHandler(this); /* - * Firefox auto-repeat works correctly only if we use a key press + * Firefox prior to v65 auto-repeat works correctly only if we use a key press * handler, other browsers handle it correctly when using a key down * handler */ - if (BrowserInfo.get().isGecko()) { + if (useOldGeckoNavigation()) { scrollBodyPanel.addKeyPressHandler(navKeyPressHandler); } else { scrollBodyPanel.addKeyDownHandler(navKeyDownHandler); @@ -862,6 +862,16 @@ public class VScrollTable extends FlowPanel rowRequestHandler = new RowRequestHandler(); } + /* + * Firefox prior to v65 auto-repeat works correctly only if we use a key press + * handler, other browsers handle it correctly when using a key down + * handler. + */ + private boolean useOldGeckoNavigation() { + return BrowserInfo.get().isGecko() + && BrowserInfo.get().getGeckoVersion() < 65; + } + @Override public void setStyleName(String style) { updateStyleNames(style, false); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VSlider.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VSlider.java index 7dbf5f9787..412a665395 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VSlider.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VSlider.java @@ -287,10 +287,7 @@ public class VSlider extends SimpleFocusablePanel increaseValue(true); } else if (DOM.eventGetType(event) == Event.MOUSEEVENTS) { processBaseEvent(event); - } else if (BrowserInfo.get().isGecko() - && DOM.eventGetType(event) == Event.ONKEYPRESS - || !BrowserInfo.get().isGecko() - && DOM.eventGetType(event) == Event.ONKEYDOWN) { + } else if (isNavigationEvent(event)) { if (handleNavigation(event.getKeyCode(), event.getCtrlKey(), event.getShiftKey())) { @@ -317,6 +314,14 @@ public class VSlider extends SimpleFocusablePanel } } + private boolean isNavigationEvent(Event event) { + if (BrowserInfo.get().isGecko() && BrowserInfo.get().getGeckoVersion() < 65) { + return DOM.eventGetType(event) == Event.ONKEYPRESS; + } else { + return DOM.eventGetType(event) == Event.ONKEYDOWN; + } + } + private void processMouseWheelEvent(final Event event) { final int dir = DOM.eventGetMouseWheelVelocityY(event); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java index 03b7e8a271..d3b8040d28 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTree.java @@ -216,11 +216,11 @@ public class VTree extends FocusElementPanel }, ContextMenuEvent.getType()); /* - * Firefox auto-repeat works correctly only if we use a key press + * Firefox prior to v65 auto-repeat works correctly only if we use a key press * handler, other browsers handle it correctly when using a key down * handler */ - if (BrowserInfo.get().isGecko()) { + if (BrowserInfo.get().isGecko() && BrowserInfo.get().getGeckoVersion() < 65) { addKeyPressHandler(this); } else { addKeyDownHandler(this); |