From 37dbc370eef7ba079bffa5610330bae135643acb 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: (cherry picked from commit de834fe3073c3eafb3fe7feff42d6107f91f1e79) --- 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 0e5aad121..e585f0480 100644 --- a/js/ui/closeDialog.js +++ b/js/ui/closeDialog.js @@ -204,7 +204,11 @@ var 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(); } });