mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Set initial focus for lovelace dialogs (#11667)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
e95065ed08
commit
f5feb1d8aa
@ -207,6 +207,7 @@ export class DialogLovelaceDashboardDetail extends LitElement {
|
||||
slot="primaryAction"
|
||||
@click=${this._updateDashboard}
|
||||
.disabled=${urlInvalid || titleInvalid || this._submitting}
|
||||
dialogInitialFocus
|
||||
>
|
||||
${this._params.urlPath
|
||||
? this._params.dashboard?.id
|
||||
|
@ -94,6 +94,7 @@ export class HuiCreateDialogCard
|
||||
.label=${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.cardpicker.by_card"
|
||||
)}
|
||||
dialogInitialFocus
|
||||
></mwc-tab>
|
||||
<mwc-tab
|
||||
.label=${this.hass!.localize(
|
||||
|
@ -53,7 +53,11 @@ export class HuiDialogDeleteCard extends LitElement {
|
||||
`
|
||||
: ""}
|
||||
</div>
|
||||
<mwc-button slot="secondaryAction" @click=${this.closeDialog}>
|
||||
<mwc-button
|
||||
slot="secondaryAction"
|
||||
@click=${this.closeDialog}
|
||||
dialogInitialFocus
|
||||
>
|
||||
${this.hass!.localize("ui.common.cancel")}
|
||||
</mwc-button>
|
||||
<mwc-button slot="primaryAction" class="warning" @click=${this._delete}>
|
||||
|
@ -207,6 +207,7 @@ export class HuiDialogEditCard
|
||||
@config-changed=${this._handleConfigChanged}
|
||||
@GUImode-changed=${this._handleGUIModeChanged}
|
||||
@editor-save=${this._save}
|
||||
dialogInitialFocus
|
||||
></hui-card-element-editor>
|
||||
</div>
|
||||
<div class="element-preview">
|
||||
@ -242,7 +243,7 @@ export class HuiDialogEditCard
|
||||
`
|
||||
: ""}
|
||||
<div slot="primaryAction" @click=${this._save}>
|
||||
<mwc-button @click=${this._cancel}>
|
||||
<mwc-button @click=${this._cancel} dialogInitialFocus>
|
||||
${this.hass!.localize("ui.common.cancel")}
|
||||
</mwc-button>
|
||||
${this._cardConfig !== undefined && this._dirty
|
||||
|
@ -92,7 +92,11 @@ export class HuiDialogSuggestCard extends LitElement {
|
||||
`
|
||||
: ""}
|
||||
</div>
|
||||
<mwc-button slot="secondaryAction" @click=${this.closeDialog}>
|
||||
<mwc-button
|
||||
slot="secondaryAction"
|
||||
@click=${this.closeDialog}
|
||||
dialogInitialFocus
|
||||
>
|
||||
${this._params.yaml
|
||||
? this.hass!.localize("ui.common.close")
|
||||
: this.hass!.localize("ui.common.cancel")}
|
||||
|
@ -56,15 +56,20 @@ export class HuiCreateDialogHeaderFooter
|
||||
>
|
||||
<div class="elements">
|
||||
${headerFooterElements.map(
|
||||
(headerFooter) =>
|
||||
(headerFooter, index) =>
|
||||
html`
|
||||
<ha-card
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-labeledby=${"card-name-" + index}
|
||||
outlined
|
||||
.type=${headerFooter.type}
|
||||
@click=${this._handleHeaderFooterPicked}
|
||||
@keyDown=${this._handleHeaderFooterPicked}
|
||||
dialogInitialFocus
|
||||
>
|
||||
<ha-svg-icon .path=${headerFooter.icon}></ha-svg-icon>
|
||||
<div>
|
||||
<div .id=${"card-name-" + index} role="none presentation">
|
||||
${this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.header-footer.types.${headerFooter.type}.name`
|
||||
)}
|
||||
@ -83,6 +88,15 @@ export class HuiCreateDialogHeaderFooter
|
||||
}
|
||||
|
||||
private async _handleHeaderFooterPicked(ev: CustomEvent): Promise<void> {
|
||||
if (
|
||||
ev instanceof KeyboardEvent &&
|
||||
ev.key !== "Enter" &&
|
||||
ev.key !== " " &&
|
||||
ev.key !== "Spacebar"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const type = (ev.currentTarget as any).type;
|
||||
let config: LovelaceHeaderFooterConfig = { type };
|
||||
|
||||
|
@ -93,6 +93,7 @@ export class HuiSaveConfig extends LitElement implements HassDialog {
|
||||
<ha-switch
|
||||
.checked=${this._emptyConfig}
|
||||
@change=${this._emptyConfigChanged}
|
||||
dialogInitialFocus
|
||||
></ha-switch
|
||||
></ha-formfield>
|
||||
`
|
||||
@ -115,6 +116,7 @@ export class HuiSaveConfig extends LitElement implements HassDialog {
|
||||
<ha-yaml-editor
|
||||
.hass=${this.hass}
|
||||
.defaultValue=${this._params!.lovelace.config}
|
||||
dialogInitialFocus
|
||||
></ha-yaml-editor>
|
||||
`}
|
||||
</div>
|
||||
|
@ -50,6 +50,7 @@ export class HuiDialogEditLovelace extends LitElement {
|
||||
.hass=${this.hass}
|
||||
.config=${this._config}
|
||||
@lovelace-config-changed=${this._ConfigChanged}
|
||||
dialogInitialFocus
|
||||
></hui-lovelace-editor>
|
||||
</div>
|
||||
<mwc-button @click=${this.closeDialog} slot="secondaryAction">
|
||||
|
@ -79,6 +79,7 @@ export class HuiDialogSelectView extends LitElement {
|
||||
@closed=${stopPropagation}
|
||||
fixedMenuPosition
|
||||
naturalMenuWidth
|
||||
dialogInitialFocus
|
||||
>
|
||||
<mwc-list-item
|
||||
value="lovelace"
|
||||
@ -104,7 +105,7 @@ export class HuiDialogSelectView extends LitElement {
|
||||
${this._config
|
||||
? this._config.views.length > 1
|
||||
? html`
|
||||
<mwc-list>
|
||||
<mwc-list dialogInitialFocus>
|
||||
${this._config.views.map(
|
||||
(view, idx) => html`
|
||||
<mwc-radio-list-item
|
||||
@ -124,7 +125,11 @@ export class HuiDialogSelectView extends LitElement {
|
||||
`
|
||||
: ""
|
||||
: html`<div>No config found.</div>`}
|
||||
<mwc-button slot="secondaryAction" @click=${this.closeDialog}>
|
||||
<mwc-button
|
||||
slot="secondaryAction"
|
||||
@click=${this.closeDialog}
|
||||
dialogInitialFocus
|
||||
>
|
||||
${this.hass!.localize("ui.common.cancel")}
|
||||
</mwc-button>
|
||||
<mwc-button slot="primaryAction" @click=${this._selectView}>
|
||||
|
@ -183,7 +183,7 @@ export class HuiDialogEditView extends LitElement {
|
||||
.selected=${this._curTabIndex}
|
||||
@selected-item-changed=${this._handleTabSelected}
|
||||
>
|
||||
<paper-tab id="tab-settings"
|
||||
<paper-tab id="tab-settings" dialogInitialFocus
|
||||
>${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.edit_view.tab_settings"
|
||||
)}</paper-tab
|
||||
|
Loading…
x
Reference in New Issue
Block a user