From de834fe3073c3eafb3fe7feff42d6107f91f1e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sun, 27 Oct 2019 18:58:16 +0100 Subject: [PATCH] closeDialog: Actually set key focus to button when grabbing key focus When setting the key focus to `this._dialog`, the default button is not automatically focused and no button has key focus. Use the `initialKeyFocus` property of the dialog instead, and set focus to the default button if the dialog is not already focused. Part-of: --- js/ui/closeDialog.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/ui/closeDialog.js b/js/ui/closeDialog.js index b3b8d4cf3..a0857298e 100644 --- a/js/ui/closeDialog.js +++ b/js/ui/closeDialog.js @@ -208,7 +208,11 @@ export const CloseDialog = GObject.registerClass({ } vfunc_focus() { - if (this._dialog) - this._dialog.grab_key_focus(); + if (!this._dialog) + return; + + const keyFocus = global.stage.key_focus; + if (!keyFocus || !this._dialog.contains(keyFocus)) + this._dialog.initialKeyFocus.grab_key_focus(); } });