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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/786>
This commit is contained in:
Jonas Dreßler 2019-10-27 18:58:16 +01:00 committed by Florian Müllner
parent d373e10a44
commit de834fe307

View File

@ -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();
}
});