Skip to content

Commit 12a892d

Browse files
committed
fix(renderers): don't store a reference to last active element if it
will never be used.
1 parent c5f4ad4 commit 12a892d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/renderers/native-dialog-renderer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ export class NativeDialogRenderer implements Renderer {
6363
}
6464

6565
private attach(dialogController: DialogController): void {
66-
this.lastActiveElement = DOM.activeElement as HTMLElement;
66+
if (dialogController.settings.restoreFocus) {
67+
this.lastActiveElement = DOM.activeElement as HTMLElement;
68+
}
6769

6870
const spacingWrapper = DOM.createElement('div'); // TODO: check if redundant
6971
spacingWrapper.appendChild(this.anchor);

src/renderers/ux-dialog-renderer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ export class DialogRenderer implements Renderer {
121121
}
122122

123123
private attach(dialogController: DialogController): void {
124-
this.lastActiveElement = DOM.activeElement as HTMLElement;
124+
if (dialogController.settings.restoreFocus) {
125+
this.lastActiveElement = DOM.activeElement as HTMLElement;
126+
}
125127

126128
const spacingWrapper = DOM.createElement('div'); // TODO: check if redundant
127129
spacingWrapper.appendChild(this.anchor);

0 commit comments

Comments
 (0)