Skip to content

Commit fe468bf

Browse files
jshaJoshua Nelson
authored and
Joshua Nelson
committed
menus: Tweak JS handling of clicks.
Prior to this change, if you clicked a menu to open it, then clicked to close it, the menu heading would still have a grey background highlighting it. That's due to a CSS rule in pure-menu that causes focused elements to have a highlighted color. To fix: unfocus the menu when it is closed via mouse (but leave it focused when it is closed via keyboard). Remove a mouseover handler that is not needed anymore.
1 parent 0bbe2ff commit fe468bf

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

static/menu.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,14 @@
5454
}
5555
if (this.parentNode === currentMenu) {
5656
closeMenu();
57+
this.blur();
5758
} else {
5859
if (currentMenu) closeMenu();
5960
openMenu(this.parentNode);
6061
}
6162
e.preventDefault();
6263
e.stopPropagation();
6364
};
64-
function menuMouseOver(e) {
65-
if (currentMenu) {
66-
if (e.target.className.indexOf("pure-menu-link") !== -1) {
67-
e.target.focus();
68-
if (e.target.parentNode.className.indexOf("pure-menu-has-children") !== -1 && e.target.parentNode !== currentMenu) {
69-
closeMenu();
70-
openMenu(e.target.parentNode);
71-
}
72-
}
73-
}
74-
}
7565
function menuKeyDown(e) {
7666
if (currentMenu) {
7767
var children = currentMenu.querySelector(".pure-menu-children");
@@ -195,7 +185,6 @@
195185
menu.firstElementChild.setAttribute("aria-haspopup", "menu");
196186
menu.firstElementChild.nextElementSibling.setAttribute("role", "menu");
197187
menu.firstElementChild.addEventListener("click", menuOnClick);
198-
menu.addEventListener("mouseover", menuMouseOver);
199188
}
200189
document.documentElement.addEventListener("keydown", menuKeyDown);
201190
})();

0 commit comments

Comments
 (0)