diff --git a/src/panels/todo/dialog-todo-item-editor.ts b/src/panels/todo/dialog-todo-item-editor.ts index ae600c9954..717b3172ad 100644 --- a/src/panels/todo/dialog-todo-item-editor.ts +++ b/src/panels/todo/dialog-todo-item-editor.ts @@ -10,10 +10,11 @@ import "../../components/ha-alert"; import "../../components/ha-button"; import "../../components/ha-checkbox"; import "../../components/ha-date-input"; -import { createCloseHeading } from "../../components/ha-dialog"; +import "../../components/ha-dialog-footer"; import "../../components/ha-textarea"; import "../../components/ha-textfield"; import "../../components/ha-time-input"; +import "../../components/ha-wa-dialog"; import { TodoItemStatus, TodoListEntityFeature, @@ -50,6 +51,8 @@ class DialogTodoItemEditor extends LitElement { @state() private _submitting = false; + @state() private _open = false; + // Dates are manipulated and displayed in the browser timezone // which may be different from the Home Assistant timezone. When // events are persisted, they are relative to the Home Assistant @@ -59,6 +62,7 @@ class DialogTodoItemEditor extends LitElement { public showDialog(params: TodoItemEditDialogParams): void { this._error = undefined; this._params = params; + this._open = true; this._timeZone = resolveTimeZone( this.hass.locale.time_zone, this.hass.config.time_zone @@ -86,6 +90,11 @@ class DialogTodoItemEditor extends LitElement { if (!this._params) { return; } + this._open = false; + } + + private _dialogClosed(): void { + this._open = false; this._error = undefined; this._params = undefined; this._due = undefined; @@ -108,16 +117,14 @@ class DialogTodoItemEditor extends LitElement { ); return html` -
${this._error @@ -136,11 +143,11 @@ class DialogTodoItemEditor extends LitElement { .label=${this.hass.localize("ui.components.todo.item.summary")} .value=${this._summary} required + autofocus @input=${this._handleSummaryChanged} .validationMessage=${this.hass.localize( "ui.common.error_required" )} - dialogInitialFocus .disabled=${!canUpdate} >
@@ -203,41 +210,43 @@ class DialogTodoItemEditor extends LitElement { ` : nothing} - ${isCreate - ? html` - - ${this.hass.localize("ui.components.todo.item.add")} - - ` - : html` - - ${this.hass.localize("ui.components.todo.item.save")} - - ${this._todoListSupportsFeature( - TodoListEntityFeature.DELETE_TODO_ITEM - ) - ? html` - - ${this.hass.localize("ui.components.todo.item.delete")} - - ` - : ""} - `} -
+ + ${isCreate + ? html` + + ${this.hass.localize("ui.components.todo.item.add")} + + ` + : html` + + ${this.hass.localize("ui.components.todo.item.save")} + + ${this._todoListSupportsFeature( + TodoListEntityFeature.DELETE_TODO_ITEM + ) + ? html` + + ${this.hass.localize("ui.components.todo.item.delete")} + + ` + : ""} + `} + + `; } @@ -415,12 +424,6 @@ class DialogTodoItemEditor extends LitElement { return [ haStyleDialog, css` - @media all and (min-width: 450px) and (min-height: 500px) { - ha-dialog { - --mdc-dialog-min-width: min(600px, 95vw); - --mdc-dialog-max-width: min(600px, 95vw); - } - } ha-alert { display: block; margin-bottom: 16px;