-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure popup card is fully hidden when not editing. #747
base: master
Are you sure you want to change the base?
Conversation
The hui-card listens for this event to observe when its child's hidden attribute changes then it hides itself.
Hmm, on further examination, this change doesn't quite work as intended for the browser-mod pop-ups in its current form because the parent hui-card removes the pop-up element from the DOM when it hides itself thereby causing the disconnectedCallback() to run and to unregister the more-info event handler from the window. Tricky. |
Setting the pop-up card element's hidden attribute completely removes it from the layout and prevents unsightly gaps in section views. Unfortunately, that also disconnects the element from the document so we can't use the connected callback to determine when to register the event handlers. To work around this issue, globally register the more-info event handler on the window and search the Lovelace configuration for the card definition so it doesn't matter whether the card is visible and it can even be defined in any view of the same dashboard.
Follows a change in Home Assistant 2024.7.
Ok, I applied the same logic I used in decluttering-card to search for pop-up cards anywhere in the dashboard configuration regardless of whether they are hidden. This change has the side-effect of expanding the scope of pop-up cards instead of being confined to usage within the same view they were defined. I think that should be fine most of the time but to improve backwards compatibility we could add a flag to govern how the card is resolved or define some new type of card with different semantics. This change also opens up the possibility of defining pop-up cards that can be referenced by name from a fireDomEvent action instead of or in addition to being tied to more-info. It could be more convenient than declaring the cards at the call site in YAML. In principle the pop-up cards could also be parameterized similar to decluttering-card in future versions. |
It seems to be more reliable this way. Without the delay the newly opened pop-up would sometimes be dismissed immediately.
As of some recent version of Home Assistant (perhaps 2024.7) the popup-card is not completely hidden when not in editing mode and it interferes with the layout of section views.
On a related front, Home Assistant 2024.7 renamed "edit-mode" to "preview" although it preserved backwards compatibility (perhaps not completely accurately though). Refer to: home-assistant/frontend#21065
You might want to rename the
edit-mode
attribute topreview
to match. I just did so in decluttering-card after tracking down the same visibility issue.Moreover, I think this code is now unnecessary and can be removed altogether: