Skip to content

Commit

Permalink
Focus cancel button on destructive confirmation dialog (#19889)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored Feb 27, 2024
1 parent bb25817 commit b993571
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dialogs/generic/dialog-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,21 @@ class DialogBox extends LitElement {
</div>
${confirmPrompt &&
html`
<mwc-button @click=${this._dismiss} slot="secondaryAction">
<mwc-button
@click=${this._dismiss}
slot="secondaryAction"
?dialogInitialFocus=${!this._params.prompt &&
this._params.destructive}
>
${this._params.dismissText
? this._params.dismissText
: this.hass.localize("ui.dialogs.generic.cancel")}
</mwc-button>
`}
<mwc-button
@click=${this._confirm}
?dialogInitialFocus=${!this._params.prompt}
?dialogInitialFocus=${!this._params.prompt &&
!this._params.destructive}
slot="primaryAction"
class=${classMap({
destructive: this._params.destructive || false,
Expand Down

0 comments on commit b993571

Please sign in to comment.