Skip to content

Close menus on esc - #1449

Merged
wash2 merged 3 commits into
pop-os:masterfrom
hojjatabdollahi:hojjat/menu-esc
Sep 22, 2026
Merged

wash2 merged 3 commits into
pop-os:masterfrom
hojjatabdollahi:hojjat/menu-esc

Conversation

@hojjatabdollahi

@hojjatabdollahi hojjatabdollahi commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Previously when a menu was open, pressing esc would be swallowed by cosmic-comp and the grab would be unset on the menu, so the second esc would be sent to the main window and it would close the open context menu.

After pop-os/cosmic-comp#2859 every menu that has keyboard grab will receive the esc, and it has to close itself.
So the first commit, closes the menu when it receives esc. But it closes the innermost menu, so if you have submenus open, every Escape closes another submenu until they're all closed.

Clicking outside the menu still closes all of them all at once.

While investigating this, I also noticed that if an action has multiple bindings the menu randomly chooses a binding, so I added a heuristic to choose the binding:

  • first go for fewer key presses
  • then go for characters instead of named keys (so ctrl+c over ctrl+insert)
  • and finally go with Ord, to stay consistent

This also updates Iced, which is unrelated, but avoids an extra PR (which Fixes #1320).


  • I have disclosed use of any AI generated code in my commit messages.
    • If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR.
    • In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

@wash2
wash2 merged commit 08a09e3 into pop-os:master Sep 22, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

text_editor: arrow-key/Home/End caret navigation broken on layer-shell + popup surfaces

2 participants