frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Lovelace creates "empty" column for conditional cards when cards are not shown

Open sgofferj opened this issue 3 years ago β€’ 49 comments

Checklist

  • [X] I have updated to the latest available Home Assistant version.
  • [X] I have cleared the cache of my browser.
  • [X] I have tried a different browser to see if it is related to my browser.

The problem

In its algorithm for organizing the cards, Lovelace also sometimes creates columns which only contain hidden conditional cards which breaks the layout.

Screenshot_20200816_110057

Expected behavior

Lovelace should not create "empty" columns. One possibility would be to append a hidden conditional card to the previous column.

Steps to reproduce

Create a Lovelace dashboard with multiple conditional cards which are hidden.

Environment

  • Home Assistant release with the issue: 0.114.1 docker
  • Last working Home Assistant release (if known): none
  • Browser and browser version: Chrome latest, Firefox latest
  • Operating system: Ubuntu 18.04, Windows 10

State of relevant entities

N.a.

Problem-relevant configuration

N.a.

Javascript errors shown in your browser console/inspector

None

Additional information

None

sgofferj avatar Aug 16 '20 08:08 sgofferj

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.

github-actions[bot] avatar Nov 14 '20 09:11 github-actions[bot]

That seems to still persist in 117.5

sgofferj avatar Nov 14 '20 09:11 sgofferj

@sgofferj if an issue is open you can assume it still persists. No need to comment as such. Just add a thumbs up to the original issue.

iantrich avatar Nov 14 '20 15:11 iantrich

I am the reporter of the issue. My comment was in reply to the bot.

sgofferj avatar Nov 14 '20 16:11 sgofferj

πŸ€¦β€β™‚οΈ of course. sorry, I'll drink more β˜• now πŸ˜„

iantrich avatar Nov 14 '20 17:11 iantrich

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.

github-actions[bot] avatar Apr 22 '21 11:04 github-actions[bot]

It still there.

bkupidura avatar Apr 22 '21 11:04 bkupidura

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.

github-actions[bot] avatar Jul 21 '21 13:07 github-actions[bot]

Issue is still present in 2021.7.3.

sgofferj avatar Jul 21 '21 15:07 sgofferj

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.

github-actions[bot] avatar Oct 19 '21 17:10 github-actions[bot]

Issue still present.

sgofferj avatar Oct 20 '21 09:10 sgofferj

@spacegaier It might be a lovelace isssue, not specifically a conditional card issue. I see the same problem with the state switch card by Thomas Loven. Somebody reported the same behavior there as a bug and I made a cross-reference to this issue here.

sgofferj avatar Oct 28 '21 09:10 sgofferj

Same here. I have different conditional cards configured to show for different weather scenarios, and the whole row is eaten by the blank cards that don't currently need to show.

Conditional

Shown

wormuths avatar Nov 13 '21 02:11 wormuths

I am also bothered by this very frustrating issue. It seems the problem is that Lovelace creates a div column and populates it with hui-conditional-cards and applies style="display: none;" to them, but they are still taking up "space" in the column so that no other items can go there.

I tried using state-switch cards. This works great for replacing a card with another based off conditions, but there's no hiding a card completely because of the Lovelace root issue. image

fikustommy avatar Nov 22 '21 14:11 fikustommy

Same with the state-switch card in a grid card. I have made a reddit post if more details can help

Bradford1138 avatar Jan 21 '22 21:01 Bradford1138

I can't believe it, but after all those years [I've found first appearence of this issue in the 2018...] this is still a problem!

no matter what card is used inside [stacks, grids etc.] the whole conditional card still is considered as "I am here, so display me!". this is annoying as hell, especially when the conditional content should "jump" to next column [even without the vertical-stack configured].

the whole right column [highlighted by me in developer's tools in chrome] should be gone, and therefore the left column should be centered image

pejotigrek avatar Feb 14 '22 12:02 pejotigrek

I found a "workaround" just trying to find a way I can apply it.

The parent element needs to either not exist or the style that's applied to the child element needs to be removed from the child and applied to the hui-conditional-card.

For example in my case I have multiple button-card elements here. Each in a conditional to only show if they're set to on. If I move the styles from the button-card child to the hui-conditional-card parent it all works.

image

image

OmgImAlexis avatar Mar 26 '22 06:03 OmgImAlexis

Issue still present in HA 2022.4.1

FsxShader2012 avatar Apr 08 '22 14:04 FsxShader2012

@FsxShader2012 I understand that this bug is annoying (I am affected by it too), but it's not necessary to comment that "it's still present". If it was fixed, this issue would have obviously been closed. It's still open because it's still present.

nicolo-ribaudo avatar Apr 08 '22 15:04 nicolo-ribaudo

I have also found a workaround, but its messy, tweaks a bit when the page is first opened, and requires work for each specific case.

Here is a gif with both the working (top) and non-working examples on top of each other: Screen Recording 2022-04-16 at 4 01 53 PM

And here is that 'tweaking' i was talking about as a page opens or is switched to: State met: Screen Recording 2022-04-16 at 4 08 39 PM State not met: Screen Recording 2022-04-16 at 4 02 10 PM

Here is my code that makes it work:

- type: horizontal-stack
  cards:
    - type: 'custom:button-card'
      template: chip_icon_only
      variables:
        ulm_chip_icon_only: 'πŸ”₯'

    - type: custom:mod-card
      card_mod:
        style: |
          :host {
            flex: 0 0 auto !important;
            {%- set sensor = states('binary_sensor.refrigerator_contact') %}
            {%- if sensor != 'on' %}display: none !important
            {%- endif %}
          }
      card:
        type: conditional
        conditions:
          - entity: binary_sensor.refrigerator_contact
            state: 'on'
        card:
          type: 'custom:button-card'
          template: chip_icon_only
          variables:
            ulm_chip_icon_only: '🧊'
          card_mod:
            style: |
              :host {
                width: 100% !important;
                max-width: none !important;
              }

    - type: 'custom:button-card'
      template: chip_icon_only
      variables:
        ulm_chip_icon_only: 'πŸͺ¨'

and here is the code that we expect to work but doesn't:

- type: horizontal-stack
  cards:
    - type: 'custom:button-card'
      template: chip_icon_only
      variables:
        ulm_chip_icon_only: 'πŸ”₯'

    - type: conditional
      conditions:
        - entity: binary_sensor.refrigerator_contact
          state: 'on'
      card:
        type: 'custom:button-card'
        template: chip_icon_only
        variables:
          ulm_chip_icon_only: '🧊'

    - type: 'custom:button-card'
      template: chip_icon_only
      variables:
        ulm_chip_icon_only: 'πŸͺ¨'

I hope this helps someone, but I also hope we can get to the bottom of this so this isn't necessary anymore

Edit on 6/23/22 BONUS: Do this if you want to be able to wrap the chips when too many show in a row

- type: custom:mod-card
  card_mod:
  style:
    hui-horizontal-stack-card:
      $: |
        div {
          flex-wrap: wrap;
          row-gap: 8px
        }
  card:
    type: horizontal-stack
    cards:
      - type: 'custom:button-card'
        template: chip_icon_only
        variables:
          ulm_chip_icon_only: 'πŸ”₯'

      - type: custom:mod-card
        card_mod:
          style: |
            :host {
              flex: 0 0 auto !important;
              {%- set sensor = states('binary_sensor.refrigerator_contact') %}
              {%- if sensor != 'on' %}display: none !important
              {%- endif %}
            }
        card:
          type: conditional
          conditions:
            - entity: binary_sensor.refrigerator_contact
              state: 'on'
          card:
            type: 'custom:button-card'
            template: chip_icon_only
            variables:
              ulm_chip_icon_only: '🧊'
            card_mod:
              style: |
                :host {
                  width: 100% !important;
                  max-width: none !important;
                }

      - type: 'custom:button-card'
        template: chip_icon_only
        variables:
          ulm_chip_icon_only: 'πŸͺ¨'

finder39 avatar Apr 16 '22 23:04 finder39

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.

github-actions[bot] avatar Sep 29 '22 01:09 github-actions[bot]

Still an issue: image

Home Assistant 2022.9.7
Supervisor 2022.09.1 Operating System 9.0 Frontend 20220907.2 - latest Firefox 105.0.1 (64-bit)

rigrig avatar Sep 29 '22 08:09 rigrig

Can somebody please turn off the stale bot? I wouldn't say that's a minor issue and everybody who posted here will be following the issue and happily close it when it has been corrected. @frenck ?

sgofferj avatar Sep 29 '22 08:09 sgofferj

Since this issue never got the attention it deserves in my opinion, I decided to create a post on it for the current "What the heck?" month of October 2022: https://community.home-assistant.io/t/471426 Votes are very much welcome to finally give this old bug more visibility. πŸ™‚

s-hutter avatar Oct 07 '22 13:10 s-hutter

Hi all! I have also had this problem, ~~but I have found a workaroud that works for me~~. I use a Lovelace dashboard that I manage through the user interface (no configuration.yaml).

~~To avoid the empty column I simply put my conditional cards into a grid card. So the hierarchy becomes Grid card β†’ Conditional card β†’ "Card to be displayed".~~

stalegjelsten avatar Nov 23 '22 22:11 stalegjelsten

I tried this just now @stalegjelsten and couldn't get it to work… Maybe I'm doing it wrong. The conditional cards still hold a spot (column) even within a grid card.

Did you wrap the entire dashboard in a grid card with multiple columns, or just that one column with a grid card (1 column grid) and the conditionals within that? Thanks in advance

cammcnab avatar Nov 23 '22 23:11 cammcnab

Hi @cammcnab, I'm sorry but I may have been to quick to celebrate and getting your hopes up. It seems that it works for be because the priority of my newly created grid card is all the way at the bottom. If I "promote" the card by pressing the ↑ arrow while rearranging the cards, the column sometimes goes blank.

I have many different non-conditional cards in my Dashboard. I have grouped all my conditional cards into the grid card with 1 column so that it becomes a vertical stack.

stalegjelsten avatar Nov 24 '22 16:11 stalegjelsten

@stalegjelsten Ahhh gotcha. Yeah that makes sense. No worries, was just excited for a fix to this!

cammcnab avatar Nov 24 '22 18:11 cammcnab

It's bizarre to me that the WTH thread got so many votes, and this has been open so long, but there has never been any dev assignment or interaction about the issue. Is there anything that can be done to at least get some attention?

sandman98321 avatar Nov 25 '22 17:11 sandman98321

Unfortunately, even the auto-entites card suffers from this issue, as the flexbox options are applied to all cards that don't explicitly overwrite it.

mrestorff avatar Jan 30 '23 13:01 mrestorff