From 4a23ddffa8094ef9bef9aefaef1eb23531d652de Mon Sep 17 00:00:00 2001 From: Dylan McCall Date: Sun, 28 Nov 2021 16:19:35 -0800 Subject: [PATCH] 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: --- js/ui/messageList.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/ui/messageList.js b/js/ui/messageList.js index 8ffdaebc1..77672a592 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -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(); } }