Closed friedit closed 1 year ago
Hi,
I have the same issue with conditional and entity filter cards in Frontend version: 20200407.2 - latest .
Still an issue with 20200519.4
.
Sometimes it works, sometimes not.
If you toggle edit-mode on/off, some cards jump around and fill the empty columns but thats not the case on hard-reload or initial request.
Still experiencing this on 0.112.2, acts if the card existed in place.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Issue is still present in 0.115.6.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Issue is still present in 2021.1.0
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Issue still ignored.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
This is still an issue with the latest version.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
This issue persists in the latest version.
This issue persists in the latest version.
I think this issue still exists. I'm using Home Assistant Core 2022.5.2 and have the same.
Can confirm this issue is still present. They are very ugly to use at the moment as they create empty space.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
On 2022.8.4 the issue is still there. ;(
Disclaimer: it's been over ~10+ years since my html/js/css days. In fact, shadow roots and custom dom elements did not exist when I last touched web.
Through some experimentation, I was able to apply a css style that appears to work, in my limited tests (in Chrome):
var colStyles = document.createElement("style");
colStyles.innerHTML = "#columns .column:not(:has(>*:not([hidden]))) { flex-grow: 0; }\n";
document.querySelector('home-assistant').shadowRoot
.querySelector("home-assistant-main").shadowRoot
.querySelector("ha-panel-lovelace").shadowRoot
.querySelector("hui-root").shadowRoot
.querySelector("hui-masonry-view").shadowRoot
.appendChild(colStyles);
I think we could add a patch/hui-masonry-view.ts
in card-mod to accomplish this.
Or I think we can just make the change here, in static get styles()
:
.column:not(:has(>*:not([hidden]))) {
flex-grow: 0;
}
The breakdown of the selectors:
div.column
- this is the element that makes up each column in the view>*:not([hidden])
- selects "direct child elements that do not contain a 'hidden' attribute" => in other words "any non-hidden elements, aka any visible element".column:not(:has(...))
- "columns that do not contain those^" => in other words: columns that do not contain any non-hidden (aka visible) cardsWe can then override the default .column { flex }
style, by setting flex-grow: 0
, which causes that column to collapse.
Unfortunately this won't work just by dropping in a Lovelace stylesheet resource, so it really can only be done by patching the custom element as in card-mod, or by fixing the styles in frontend. And another option would be a custom javascript resource that does the DOM traversal like above.
Note that there is not 100% support for these selectors:
:has()
selectorAlso note that this only works if the element is explicitly hidden (by setting element.hidden = true
, or html <hui-conditional-card hidden>
). In other words, it will not work to test visibility of an element that is hidden by any other means (like a .hidden class or other css rule that hides it).
I confirmed that adding this as a local javascript resource appears to resolve the empty column. However, this is a very exact DOM path that it has to traverse, so it is pretty fragile.
// file: /config/www/fix-conditional-column.js
// added at http://$HA/config/lovelace/resources, with path: /local/fix-conditional-column.js
customElements.whenDefined("hui-masonry-view").then(() => {
const doPatch = function () {
var colStyles = document.createElement("style");
colStyles.innerHTML = "#columns .column:not(:has(>*:not([hidden]))) { flex-grow: 0; }\n";
// FIXME: this layout may not always be valid. Would be better to patch it directly in masonry
document.querySelector('home-assistant').shadowRoot
.querySelector("home-assistant-main").shadowRoot
.querySelector("ha-panel-lovelace").shadowRoot
.querySelector("hui-root").shadowRoot
.querySelector("hui-masonry-view").shadowRoot
.appendChild(colStyles);
};
// hui-masonry-view has been defined, but that doesn't mean it has been created under hui-root yet. Add a delay.
setTimeout(doPatch, 100);
});
Would appreciate if others having this issue could test out the above. If it appears to be working, I don't mind opening a PR to add the style.
UPDATE: this isn't a perfect fix, as there are still times where these selectors won't be used. The way the card-mod handled this is probably better (by defining a custom-pseudo-selector syntax that uses Promise/await to wait for each selector+shadow to become available before proceeding). However, if the change in #16351 is merged, then we don't need to do this. If that doesn't get accepted for any reason, my next choice would likely be a new PR for card-mod that would do it with a monkeypatch.
Just thinking out loud here: someone else mentioned in another (duplicate, now since closed) issue that this is actually (somehow?) the longest standing (frontend) issue in HA history. If that's true, I'll be happy to wear that badge of honor 😎
Can anybody help me please? I can't get this combination of cards to work.
The idea is to have a card that only shows up when there's an update. If it's an update from HACS, it shows witch update it is (instead of only having a number of how many updates HACS has). The updates from within home assistant are already specified, so they show up as well)
Here's the code:
type: custom:auto-entities
show_header_toggle: false
card:
type: entities
title: Add-on & Integratie Updates
show_header_toggle: false
filter:
include:
- domain: update
state: 'on'
- entity_id: sensor.hacs
state: '! 0'
show_empty: false
sort:
method: last_triggered
- type: markdown
title: HACS Updates
content: |-
{%- if is_state('sensor.hacs','0') -%}
<b><font color=green>No updates</font></b>
{%- else -%}
<table width=100%>
{%- set hacs_updates = state_attr('sensor.hacs','repositories') -%}
{%- for hacs_update in hacs_updates -%}
<tr><td><b><font color=red>{{[hacs_update][0]['display_name']}}</b></font></td><td>{{[hacs_update][0]['installed_version']}}</td><td>{{[hacs_update][0]['available_version']}}</td></tr>
{%- endfor -%}
</table>
{%- endif -%}
Checklist
The problem
When using conditional cards and/or entity-filter cards and all of them are hidden the first column is empty on desktop browsers. See screenshot.
Expected behavior
When using conditional cards and/or entity-filter cards the layout should adapt if all cards are hidden - meaning there shouldn't be a big hole in the frontend by having a column not having any content.
Steps to reproduce
Add conditional cards and entity-filter cards on the top of your view. In my case, I have 1 conditional card, followed by 3 entity-filter cards. Afterward add more cards. If none of the conditional and entity-filter cards are visible the first column is empty. This is only visible on desktop browsers - not on mobile.
Environment
Problem-relevant configuration
Javascript errors shown in your browser console/inspector
Additional information
This seems to have already been reported in earlier versions: https://github.com/home-assistant/frontend/issues/1686