Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Update Badges repeat on all custom entries #9

Open
n00bcodr opened this issue Mar 31, 2022 · 6 comments
Open

Update Badges repeat on all custom entries #9

n00bcodr opened this issue Mar 31, 2022 · 6 comments

Comments

@n00bcodr
Copy link

2022.4.0b0 introduces updates this is also introducing a badge with the number of updates for configuration.

Like below
image

but with custom sidebar, those updates are showing up on all custom entries and the badge is also offset a little, which is not showing the complete number.

like below

image

@dmyoung9
Copy link

dmyoung9 commented Apr 2, 2022

I can confirm the same behavior:

This is in the Android app, so they aren't cut off (because the sidebar is expanded), but I am definitely having that badge on all my custom items.

@dmyoung9
Copy link

dmyoung9 commented Apr 2, 2022

Correction: This is behaving slightly differently for me on PC (Chrome) that in is in the Android app.

image

It isn't showing on every single custom icon, but it is on a couple, so I'm not sure what's the determining factor.

@dmyoung9
Copy link

dmyoung9 commented Apr 7, 2022

@galloween Any ideas on how to solve this?

@n00bcodr n00bcodr changed the title Issue with UI on 2022.4.0b0 Update Badges repeat on all custom entries Jan 23, 2023
@ianwitherow
Copy link

ianwitherow commented Feb 23, 2023

This was bothering me. I can submit a PR but I haven't been seeing much communication or activity on this repo by the author so it might go unmerged. (Edit - never mind, clearly wasn't looking in the right place! @galloween Let me know if you'd like me to submit a PR, or if you'd rather address this a different way)

The problem is that when you add a new item it clones an existing item, modifies it, then appends it. If the cloned item has a badge, the new item will too.

Here's my fix:

  • Edit your custom-sidebar-v2/custom-sidebar-v2.js file (I'm using HACS and mine was in www/community)

  • Find the function createItem (should be around line 277)

  • Anywhere in the if (cln) {} block, add this:

        if (config_entry.new_item) {
          // If the cloned item has a configuration badge, remove it.
          cln.querySelector(".configuration-badge")?.remove();
        }

E.g.,
image

This will ensure any items that you're adding (instead of moving around) will not have the number badge.

Side note: I struggled with getting Home Assistant to serve up a current version of the custom-sidebar-v2.js file instead of feeding me a cached copy (tried hard refreshing, clearing cache, restarting HA; always got the original copy). I ended up changing the .js filename (and updating the reference in my configuration.yaml's extra_module_url). If someone could tell me how to actually clear the cache for that I'd appreciate it! I'm using HACS which might have something to do with it.

Second edit: Re-reading the original message in this issue, I'm wondering if this can happen to folks even when an item isn't flagged with "new_item": true. If this is the case, we could instead add another option to the entry items such as "badge": false. Just a thought.

@n00bcodr
Copy link
Author

I just added your forked repo.
I think it only shows on "new_item". But will test it and see if it is showing on all the entries.

@n00bcodr
Copy link
Author

n00bcodr commented Apr 6, 2023

@ianwitherow do you plan to maintain your fork? 😄
This breaks on the latest HA release (2023.4)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants