Skip to content

Commit

Permalink
Listbox examples: Prevent default arrow key scroll only when moving f…
Browse files Browse the repository at this point in the history
…ocus in listbox (pull #1294)

Resolves #1249 by changing up and down arrow key handling in listbox.
With this change, default scroll behavior is only prevented if focus is actually moved.
This allows the up/down arrow keys to scroll the listbox to its upper and lower bounds.

Co-authored-by: Matt King <a11yThinker@Gmail.com>
  • Loading branch information
smhigley and mcking65 committed Jan 28, 2020
1 parent eec5af6 commit ade643a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/listbox/js/listbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ aria.Listbox.prototype.checkKeyPress = function (evt) {
break;
case aria.KeyCode.UP:
case aria.KeyCode.DOWN:
evt.preventDefault();

if (!this.activeDescendant) {
// focus first option if no option was previously focused, and perform no other actions
Expand All @@ -119,6 +118,7 @@ aria.Listbox.prototype.checkKeyPress = function (evt) {
}

if (this.moveUpDownEnabled && evt.altKey) {
evt.preventDefault();
if (key === aria.KeyCode.UP) {
this.moveUpItems();
}
Expand All @@ -137,6 +137,7 @@ aria.Listbox.prototype.checkKeyPress = function (evt) {

if (nextItem) {
this.focusItem(nextItem);
evt.preventDefault();
}

break;
Expand Down

0 comments on commit ade643a

Please sign in to comment.