messageList: Give focus to next message on delete

When the user deletes a message using the keyboard, set the keyboard
focus to the next message, or to the list container itself, so it
remains possible to navigate using the keyboard.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/502
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2053>
This commit is contained in:
Dylan McCall 2021-11-28 16:19:35 -08:00 committed by Marge Bot
parent b37fa61eb0
commit 4a23ddffa8

View File

@ -663,12 +663,24 @@ var MessageListSection = GObject.registerClass({
}
removeMessage(message, animate) {
if (!this._messages.includes(message))
const messages = this._messages;
if (!messages.includes(message))
throw new Error(`Impossible to remove untracked message`);
let listItem = message.get_parent();
listItem._connectionsIds.forEach(id => message.disconnect(id));
let nextMessage = null;
if (message.has_key_focus()) {
const index = messages.indexOf(message);
nextMessage =
messages[index + 1] ||
messages[index - 1] ||
this._list;
}
if (animate) {
listItem.ease({
scale_x: 0,
@ -677,10 +689,12 @@ var MessageListSection = GObject.registerClass({
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => {
listItem.destroy();
nextMessage?.grab_key_focus();
},
});
} else {
listItem.destroy();
nextMessage?.grab_key_focus();
}
}