Fix schedule form rendering after disconnect (#18401)

This commit is contained in:
karwosts 2023-10-25 06:21:05 -07:00 committed by GitHub
parent 763f80b46a
commit b0b7e77e28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,6 +93,20 @@ class HaScheduleForm extends LitElement {
}
}
public disconnectedCallback(): void {
super.disconnectedCallback();
this.calendar?.destroy();
this.calendar = undefined;
this.renderRoot.querySelector("style[data-fullcalendar]")?.remove();
}
public connectedCallback(): void {
super.connectedCallback();
if (this.hasUpdated && !this.calendar) {
this.setupCalendar();
}
}
public focus() {
this.updateComplete.then(
() =>
@ -165,6 +179,10 @@ class HaScheduleForm extends LitElement {
}
protected firstUpdated(): void {
this.setupCalendar();
}
private setupCalendar(): void {
const config: CalendarOptions = {
...defaultFullCalendarConfig,
locale: this.hass.language,