From bd685c13796d89bd864ac509d1b141255700a03b Mon Sep 17 00:00:00 2001 From: karwosts Date: Wed, 25 Oct 2023 06:02:49 -0700 Subject: [PATCH] Fix schedule form rendering after disconnect --- .../config/helpers/forms/ha-schedule-form.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/panels/config/helpers/forms/ha-schedule-form.ts b/src/panels/config/helpers/forms/ha-schedule-form.ts index f38c36b3ba3f..a1c08c083e6b 100644 --- a/src/panels/config/helpers/forms/ha-schedule-form.ts +++ b/src/panels/config/helpers/forms/ha-schedule-form.ts @@ -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,