Repository navigation
The escape key should close the right click menu on desktop #98163
Description
Activity
- addeda: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsa: desktopRunning on desktopRunning on desktop
on Feb 10, 2022 This could be considered a component of #94965, since it doesn't look like this is the only type of "de-selection" that the ESC key should handle in Flutter's built-in widgets.
Good point. I left a comment on that issue. If that issue doesn't have the same focus problem that this one does, then it will be even easier to fix.
Reverted in #98600
@justinmc There's no way to get a shortcut when nothing is focused, but you can listen for key events globally through a handler on
HardwareKeyboard, and if escape is pressed while the context menu is open, close the menu.Reacted by Justin McCandless- addedP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Feb 17, 2022 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Mar 16, 2022
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone (PR merged)
When the right click menu is open, pressing the escape key should close it. I confirmed that this is the native behavior on Mac and Windows. I assume Linux is the same but I haven't tried.
Steps to reproduce
Expected: The context menu closes.
Actual: Nothing happens and the context menu remains on the screen.
Solution
We could add a text editing shortcut for this and it should work for now, but if we allow context menus outside of EditableText (as mentioned in #90563), then the Shortcuts widget won't receive the escape when nothing is focused and it won't always work.
@gspencergoog Is it possible to receive a Shortcut when nothing is focused?
Code