Skip to content

Commit 7f7f0c4

Browse files
authored
Fix for autofocus when modal dialogs are opened (#13802)
This fixes autofocus when modal dialogs are opened by connecting to the 'opened' signal before showing the dialog. When the animation time is greater than zero, the signal emission is delayed, so that it triggers after connecting. When the animation time is 0, signal emission is instant, so that the signal connect happened after the onComplete() function of the animation is called.
1 parent d0c4e07 commit 7f7f0c4

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

js/ui/modalDialog.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ class ModalDialog extends BaseDialog.BaseDialog {
143143
if (!this.pushModal(timestamp))
144144
return false;
145145

146+
this._openedId = this.connect('opened', () => {
147+
this.disconnect(this._openedId);
148+
this._openedId = 0;
149+
this._grabInitialKeyFocus();
150+
});
151+
146152
this._fadeOpen();
147153

148154
if (this._lightbox && !this._keyboardVisibleId) {
@@ -154,12 +160,6 @@ class ModalDialog extends BaseDialog.BaseDialog {
154160
this._raiseKeyboardAboveDialog();
155161
}
156162

157-
this._openedId = this.connect('opened', () => {
158-
this.disconnect(this._openedId);
159-
this._openedId = 0;
160-
this._grabInitialKeyFocus();
161-
});
162-
163163
return true;
164164
}
165165

0 commit comments

Comments
 (0)