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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2525>
This commit is contained in:
Lukáš Tyrychtr 2022-11-01 16:54:54 +01:00 committed by Marge Bot
parent c7208df8b3
commit c97825e832

View File

@ -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;
}