Skip to content

Commit

Permalink
Dismiss menu on Cancel when at top level
Browse files Browse the repository at this point in the history
  • Loading branch information
tiliv committed May 8, 2024
1 parent fd46067 commit 032600f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/DisplayMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ export default function DisplayMenu({
const keyHandler = (e) => {
if (e.key === keyMap.cancel) {
setMenus((menus) => {
if (menus.length > 1) {
if (menus[0].autoStart || menus.length === 1) {
window.dispatchEvent(new CustomEvent('interaction', { detail: null }));
return [];
} else if (menus.length > 1) {
const newMenus = menus.slice(0, -1);
setSelected(newMenus[newMenus.length - 1].selected);
return newMenus;
Expand Down

0 comments on commit 032600f

Please sign in to comment.