diff options
author | Bogdan Udrescu <bogdan@vaadin.com> | 2014-08-11 13:08:39 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-14 06:33:55 +0000 |
commit | 52b98ccd173682355af9396ce216ce5a98993194 (patch) | |
tree | dba17d0cb8c60c39a11c9c7d3b48d57859d083f3 /client | |
parent | c5c6a78787dd1d86c511b50361efc9acedee6684 (diff) | |
download | vaadin-framework-52b98ccd173682355af9396ce216ce5a98993194.tar.gz vaadin-framework-52b98ccd173682355af9396ce216ce5a98993194.zip |
Prevent browser to scroll when space it pressed on a TabSheet (#14320)
Browser page scroll by default when space key is pressed.
The TabSheet uses the space key (32) to select the tab
when navigating using left/right keys. So when the space
is pressed the default browser page scroll behavior is
now prevented.
Change-Id: I8c3c7c4904109018d2f91447235e30dbd29eec5d
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VTabsheet.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 15d9c83c49..35fdebf353 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -1280,6 +1280,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, if (event.getSource() instanceof Tab) { int keycode = event.getNativeEvent().getKeyCode(); + // Scroll throw the tabs. if (!event.isAnyModifierKeyDown()) { if (keycode == getPreviousTabKey()) { selectPreviousTab(); @@ -1294,6 +1295,10 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } } else if (keycode == getSelectTabKey()) { loadTabSheet(focusedTabIndex); + + // Prevent the page from scrolling when hitting space + // (select key) to select the current tab. + event.preventDefault(); } } } @@ -1307,8 +1312,17 @@ public class VTabsheet extends VTabsheetBase implements Focusable, return KeyCodes.KEY_LEFT; } + /** + * Gets the key to activate the selected tab when navigating using + * previous/next (left/right) keys. + * + * @return the key to activate the selected tab. + * + * @see #getNextTabKey() + * @see #getPreviousTabKey() + */ protected int getSelectTabKey() { - return 32; // Space key + return KeyCodes.KEY_SPACE; } /** |