GavinJoyce/ember-headlessui

`<Menu>` doesn't close items dropdown on `Escape`

achambers opened this issue · 1 comments

We should make the <Menu> dropdown close when Escape is hit. I suspect it should go here.

onKeydown(event) {
switch (event.key) {
// Ref: https://www.w3.org/TR/wai-aria-practices-1.2/#keyboard-interaction-12
case 'Enter':
if (this.args.activeItem) {
this.args.activeItem.element.click();
}
this.args.closeMenu();
break;
case 'ArrowDown':
return this.args.goToNextItem();
case 'ArrowUp':
return this.args.goToPreviousItem();
}
}

I'm making some other improvements to Menu right now, including implementing the item search functionality. I'll take care of this one!