From c97825e832b0eedfea7ea2866373383c49e8386a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tyrychtr?= Date: Tue, 1 Nov 2022 16:54:54 +0100 Subject: [PATCH] popupMenu: Allow to use the up and down arrows to wrap around This aligns the keyboard navigation behavior with similar menus in other desktop environments and with GTK itself. It allows the users to move in the menu using already known patterns and makes the operation quicker in some cases, especially as many users don't know about the tab and shift+tab behavior. Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6017 Part-of: --- js/ui/popupMenu.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 531753161..60da5460d 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -167,6 +167,16 @@ export const PopupBaseMenuItem = GObject.registerClass({ this.activate(event); return Clutter.EVENT_STOP; } + + // Support wrapping navigation in the menu + if (symbol === Clutter.KEY_Up || symbol === Clutter.KEY_Down) { + const group = global.focus_manager.get_group(this); + const direction = symbol === Clutter.KEY_Up + ? St.DirectionType.UP + : St.DirectionType.DOWN; + if (group?.navigate_focus(this, direction, true)) + return Clutter.EVENT_STOP; + } return Clutter.EVENT_PROPAGATE; }