Skip to content

Commit

Permalink
Navigation Menubar Example: Fix escape key behavior when in menubar o…
Browse files Browse the repository at this point in the history
…r in second level submenu (pull #740)

For issues #451 and #795, change escape key processing.
When focus in menubar, close any open submenu.
When focus in second level submenu, close second level menu and focus parent menuitem.
  • Loading branch information
jongund authored and mcking65 committed Jun 27, 2018
1 parent dc1ed44 commit 15b87d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 3 additions & 0 deletions examples/menubar/menubar-1/js/MenubarItemLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ MenubarItem.prototype.handleKeydown = function (event) {
this.popupMenu.close(true);
break;

case this.keyCode.ESC:
this.popupMenu.close(true);
break;

default:
if (isPrintableCharacter(char)) {
Expand Down
1 change: 0 additions & 1 deletion examples/menubar/menubar-1/js/PopupMenuItemLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ MenuItem.prototype.handleKeydown = function (event) {
break;

case this.keyCode.RIGHT:
console.log('[MenuItem][handleKeydown]: ' + this.menu.controller.isMenubarItem);
if (this.popupMenu) {
this.popupMenu.open();
this.popupMenu.setFocusToFirstItem();
Expand Down
10 changes: 3 additions & 7 deletions examples/menubar/menubar-1/js/PopupMenuLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ PopupMenu.prototype.setFocusToController = function (command, flag) {
}

if (command === '') {
setFocusToMenubarItem(this.controller, true);
if (this.controller && this.controller.domNode) {
this.controller.domNode.focus();
}
return;
}

Expand Down Expand Up @@ -213,8 +215,6 @@ PopupMenu.prototype.open = function () {
// Get position and bounding rectangle of controller object's DOM node
var rect = this.controller.domNode.getBoundingClientRect();

console.log('[PopupMenu][open]');

// Set CSS properties
if (!this.controller.isMenubarItem) {
this.domNode.parentNode.style.position = 'relative';
Expand All @@ -236,8 +236,6 @@ PopupMenu.prototype.open = function () {

PopupMenu.prototype.close = function (force) {

console.log('[PopupMenu][close][force]: ' + force);

var controllerHasHover = this.controller.hasHover;

var hasFocus = this.hasFocus;
Expand All @@ -249,8 +247,6 @@ PopupMenu.prototype.close = function (force) {
}
}

console.log('[PopupMenu][close][hasFocus]: ' + hasFocus);

if (!this.controller.isMenubarItem) {
controllerHasHover = false;
}
Expand Down

0 comments on commit 15b87d9

Please sign in to comment.