[polari] roomList: Restore focus on popover close
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomList: Restore focus on popover close
- Date: Sat, 4 Sep 2021 00:53:06 +0000 (UTC)
commit 2d226602ed536182f6698c92bd9dd265143183a4
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Aug 20 07:29:54 2021 +0200
roomList: Restore focus on popover close
If a widget is hidden that contains the focus, GTK will move the focus
(as if TAB was pressed). For popovers in the room list this translates
to switching to the room that is located after the element that popped
up the popover, which is not the behavior we want.
Instead, remember the widget that had the focus when the popover was
opened, and restore it on close.
Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/235>
src/roomList.js | 9 +++++++++
1 file changed, 9 insertions(+)
---
diff --git a/src/roomList.js b/src/roomList.js
index 6e206602..d1a1eaa9 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -259,9 +259,15 @@ class RoomRowPopover extends Gtk.PopoverMenu {
vfunc_map() {
if (this._row.room.type !== Tp.HandleType.ROOM)
this._updateMuteItem();
+ this._previousFocus = this.get_root().get_focus();
super.vfunc_map();
}
+ vfunc_unmap() {
+ this._previousFocus.grab_focus();
+ super.vfunc_unmap();
+ }
+
_updateMuteItem() {
this._menu.remove(0);
@@ -341,6 +347,8 @@ const RoomListHeader = GObject.registerClass({
return;
this._clickGesture.set_state(Gtk.EventSequenceState.CLAIMED);
+
+ this._previousFocus = this.get_root().get_focus();
this._popover?.popup();
});
@@ -350,6 +358,7 @@ const RoomListHeader = GObject.registerClass({
this.popover.connect('notify::visible', _onPopoverVisibleChanged);
this.popover.connect('closed', () => {
this._popoverPassword.text = '';
+ this._previousFocus?.grab_focus();
});
let target = new GLib.Variant('o', this._account.get_object_path());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]