Skip to content

Commit

Permalink
Navigation Menu Button Example: fix unreachable code and shift-tab no…
Browse files Browse the repository at this point in the history
…t closing menu (pull #716)

* fixed unreachable code problem described in issue #396.
* Made shift-tab close menu as described in issue #588.
  • Loading branch information
jongund authored and mcking65 committed Jun 27, 2018
1 parent 15b87d9 commit 8bc433e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions examples/menu-button/js/MenuItemLinks.js
Expand Up @@ -76,15 +76,17 @@ MenuItemLinks.prototype.handleKeydown = function (event) {
if (event.shiftKey) {
if (isPrintableCharacter(char)) {
this.menu.setFocusByFirstCharacter(this, char);
flag = true;
}

if (event.keyCode === this.keyCode.TAB) {
this.menu.setFocusToController();
this.menu.close(true);
}
}
else {
switch (event.keyCode) {

case this.keyCode.SPACE:
flag = true;
break;

case this.keyCode.ESC:
this.menu.setFocusToController();
this.menu.close(true);
Expand Down
2 changes: 1 addition & 1 deletion examples/menu-button/js/PopupMenuLinks.js
Expand Up @@ -48,7 +48,7 @@ var PopupMenuLinks = function (domNode, controllerObj) {
var childElement = domNode.firstElementChild;
while (childElement) {
var menuitem = childElement.firstElementChild;
if (menuitem && menuitem === 'A') {
if (menuitem && menuitem.tagName !== 'A') {
throw new Error(msgPrefix + 'has descendant elements that are not A elements.');
}
childElement = childElement.nextElementSibling;
Expand Down

0 comments on commit 8bc433e

Please sign in to comment.