Skip to content

Commit

Permalink
fix(dialog): focus before animation to fix a11y
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 543557352
  • Loading branch information
Elliott Marquez authored and copybara-github committed Jun 26, 2023
1 parent fb4d9c8 commit 61e5e87
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dialog/lib/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ export class Dialog extends LitElement {
private async performTransition(shouldDispatchAction: boolean) {
// TODO: pause here only to avoid a double update warning.
await this.updateComplete;
// Focus initial element.
if (this.open) {
this.focus();
}
this.showingOpen = this.open;
if (shouldDispatchAction) {
this.dispatchActionEvent(this.open ? 'opening' : 'closing');
Expand Down Expand Up @@ -415,10 +419,6 @@ export class Dialog extends LitElement {
Dialog.setDocumentScrollingDisabled(this.open);
}
}
// Focus initial element.
if (this.open) {
this.focus();
}
if (shouldDispatchAction) {
this.dispatchActionEvent(this.open ? 'opened' : 'closed');
}
Expand Down

0 comments on commit 61e5e87

Please sign in to comment.