Close entity registry dialog when navigation away (#6511)

This commit is contained in:
Bram Kragten 2020-08-04 11:13:55 +02:00 committed by GitHub
parent 6991403203
commit bb5f6e88d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 5 deletions

View File

@ -97,6 +97,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
</h3> </h3>
<a <a
href=${`/config/integrations#config_entry=${relatedConfigEntryId}`} href=${`/config/integrations#config_entry=${relatedConfigEntryId}`}
@click=${this._navigateAwayClose}
> >
${this.hass.localize(`component.${entry.domain}.title`)}: ${this.hass.localize(`component.${entry.domain}.title`)}:
${entry.title} ${entry.title}
@ -116,7 +117,10 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
<h3> <h3>
${this.hass.localize("ui.components.related-items.device")}: ${this.hass.localize("ui.components.related-items.device")}:
</h3> </h3>
<a href="/config/devices/device/${relatedDeviceId}"> <a
href="/config/devices/device/${relatedDeviceId}"
@click=${this._navigateAwayClose}
>
${device.name_by_user || device.name} ${device.name_by_user || device.name}
</a> </a>
`; `;
@ -134,7 +138,10 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
<h3> <h3>
${this.hass.localize("ui.components.related-items.area")}: ${this.hass.localize("ui.components.related-items.area")}:
</h3> </h3>
<a href="/config/areas/area/${relatedAreaId}"> <a
href="/config/areas/area/${relatedAreaId}"
@click=${this._navigateAwayClose}
>
${area.name} ${area.name}
</a> </a>
`; `;
@ -278,6 +285,12 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
`; `;
} }
private async _navigateAwayClose() {
// allow new page to open before closing dialog
await new Promise((resolve) => setTimeout(resolve, 0));
fireEvent(this, "close-dialog");
}
private async _findRelated() { private async _findRelated() {
this._related = await findRelated(this.hass, this.itemType, this.itemId); this._related = await findRelated(this.hass, this.itemType, this.itemId);
await this.updateComplete; await this.updateComplete;

View File

@ -73,7 +73,7 @@ export class EntityRegistrySettings extends LitElement {
return html` return html`
${!stateObj ${!stateObj
? html` ? html`
<div> <div class="container">
${this.hass!.localize( ${this.hass!.localize(
"ui.dialogs.entity_registry.editor.unavailable" "ui.dialogs.entity_registry.editor.unavailable"
)} )}
@ -81,7 +81,7 @@ export class EntityRegistrySettings extends LitElement {
` `
: ""} : ""}
${this._error ? html` <div class="error">${this._error}</div> ` : ""} ${this._error ? html` <div class="error">${this._error}</div> ` : ""}
<div class="form"> <div class="form container">
<paper-input <paper-input
.value=${this._name} .value=${this._name}
@value-changed=${this._nameChanged} @value-changed=${this._nameChanged}
@ -227,8 +227,10 @@ export class EntityRegistrySettings extends LitElement {
:host { :host {
display: block; display: block;
} }
.form { .container {
padding: 20px 24px; padding: 20px 24px;
}
.form {
margin-bottom: 53px; margin-bottom: 53px;
} }
.buttons { .buttons {