Close dialog when clicked on link (#16690)

This commit is contained in:
Bram Kragten
2023-05-31 14:01:47 +02:00
committed by GitHub
parent 046475e7ac
commit 585db6ab3f
3 changed files with 25 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ import type { DataEntryFlowStepForm } from "../../data/data_entry_flow";
import type { HomeAssistant } from "../../types";
import type { FlowConfig } from "./show-dialog-data-entry-flow";
import { configFlowContentStyles } from "./styles";
import { isNavigationClick } from "../../common/dom/is-navigation-click";
@customElement("step-flow-form")
class StepFlowForm extends LitElement {
@@ -47,7 +48,7 @@ class StepFlowForm extends LitElement {
return html`
<h2>${this.flowConfig.renderShowFormStepHeader(this.hass, this.step)}</h2>
<div class="content">
<div class="content" @click=${this._clickHandler}>
${this.flowConfig.renderShowFormStepDescription(this.hass, this.step)}
${this._errorMsg
? html`<ha-alert alert-type="error">${this._errorMsg}</ha-alert>`
@@ -92,6 +93,14 @@ class StepFlowForm extends LitElement {
this.addEventListener("keydown", this._handleKeyDown);
}
private _clickHandler(ev: MouseEvent) {
if (isNavigationClick(ev, false)) {
fireEvent(this, "flow-update", {
step: undefined,
});
}
}
private _handleKeyDown = (ev: KeyboardEvent) => {
if (ev.key === "Enter") {
this._submitStep();