Skip to content

Commit 3472953

Browse files
committed
Do not scroll when closing the menu with space
Fixes #1082
1 parent f6fd6cf commit 3472953

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

static/menu.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,22 @@
128128
break;
129129
case "enter":
130130
case "return":
131-
case "space":
132-
case " ":
133-
// enter, return, and space have the default browser behavior,
131+
// enter and return have the default browser behavior,
134132
// but they also close the menu
135133
// this behavior is identical between both the WAI example, and GitHub's
136134
setTimeout(function() {
137135
closeMenu();
138136
}, 100);
139137
break;
138+
case "space":
139+
case " ":
140+
// space closes the menu, but does not engage default behavior,
141+
// which would be to scroll the page
142+
// this behavior is identical between both the WAI example, and GitHub's
143+
closeMenu();
144+
e.preventDefault();
145+
e.stopPropagation();
146+
break;
140147
case "home":
141148
case "pageup":
142149
// home: focus first menu item.

0 commit comments

Comments
 (0)