|
140 | 140 | // space closes the menu, and activates the current link
|
141 | 141 | // this behavior is identical between both the WAI example, and GitHub's
|
142 | 142 | if (document.activeElement instanceof HTMLAnchorElement && !document.activeElement.hasAttribute("aria-haspopup")) {
|
| 143 | + // It's supposed to copy the behaviour of the WAI Menu Bar |
| 144 | + // page, and of GitHub's menus. I've been using these two |
| 145 | + // sources to judge what is basically "industry standard" |
| 146 | + // behaviour for menu keyboard activity on the web. |
| 147 | + // |
| 148 | + // On GitHub, here's what I notice: |
| 149 | + // |
| 150 | + // 1 If you click open a menu, the menu button remains |
| 151 | + // focused. If, in this stage, I press space, the menu will |
| 152 | + // close. |
| 153 | + // |
| 154 | + // 2 If I use the arrow keys to focus a menu item, and then |
| 155 | + // press space, the menu item will be activated. For |
| 156 | + // example, clicking "+", then pressing down, then pressing |
| 157 | + // space will open the New Repository page. |
| 158 | + // |
| 159 | + // Behaviour 1 is why the |
| 160 | + // `!document.activeElement.hasAttribute("aria-haspopup")` |
| 161 | + // condition is there. It's to make sure the menu-link on |
| 162 | + // things like the About dropdown don't get activated. |
| 163 | + // Behaviour 2 is why this code is required at all; I want to |
| 164 | + // activate the currently highlighted menu item. |
143 | 165 | document.activeElement.click();
|
144 | 166 | }
|
145 | 167 | setTimeout(function() {
|
|
0 commit comments