File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,14 +18,18 @@ import '~/styles/app.css'
1818class LiebePanel extends HTMLElement {
1919 private _hass : HomeAssistant | null = null
2020 private root ?: ReactDOM . Root
21+ private initialized = false
2122
2223 set hass ( hass : HomeAssistant ) {
2324 this . _hass = hass
2425 this . render ( )
2526 }
2627
2728 connectedCallback ( ) {
28- if ( ! this . root ) {
29+ // Only initialize once - don't recreate on reconnection
30+ if ( ! this . initialized ) {
31+ this . initialized = true
32+
2933 const shadow = this . attachShadow ( { mode : 'open' } )
3034 const container = document . createElement ( 'div' )
3135 container . style . height = '100%'
@@ -49,11 +53,13 @@ class LiebePanel extends HTMLElement {
4953
5054 this . root = ReactDOM . createRoot ( container )
5155 }
56+
5257 this . render ( )
5358 }
5459
5560 disconnectedCallback ( ) {
56- this . root ?. unmount ( )
61+ // Do NOT unmount or cleanup - Home Assistant will re-add this element
62+ // when the user navigates back to the panel
5763 }
5864
5965 private render ( ) {
You can’t perform that action at this time.
0 commit comments