-
Notifications
You must be signed in to change notification settings - Fork 168
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
Wait until hass initialized before merging card and theme styles #284
base: master
Are you sure you want to change the base?
Wait until hass initialized before merging card and theme styles #284
Conversation
# Conflicts: # card-mod.js # package-lock.json
src/helpers.ts
Outdated
@@ -168,9 +173,9 @@ export function getResources() { | |||
const retval = []; | |||
for (const script of scriptElements) { | |||
if (script?.innerText?.trim()?.startsWith("import(")) { | |||
const imports = script.innerText.split("\n")?.map((e) => e.trim()); | |||
const imports = script.innerText.split(/[\n;]/)?.map((e) => e.trim()).filter(e => e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part seems unrelated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, yes, you are correct. This was a one-liner fix that was later implemented in #278 and is not needed here. I pushed another commit reverting this change.
Unfortunately this does not work for me. I do not experience this behaviour with card-embedded styles; my beef is with global styles that are defined in custom Home Assistant theme. Here - in my case - the problem is the missing value of |
This pull request may fix issues described in #152 (in some cases).
I experienced similar behavior - styles not being applied after page refresh - on one of my dashboards. I suspect some race condition occurs when
card-mod
styles are being applied as styles are correctly applied on some of my dashboards and randomly on others.Please note that I am using a custom
card-mod
theme and the missing styles are set globally in the theme.I noticed that sometimes
card-mod
did not read value of CSS variable--card-mod-theme
correctly when debugging the issue. Movingawait hass()
in front ofgetPropertyValue("--card-mod-theme")
appears to block the app for just enough time that variable--card-mod-theme
is being set and can be read bycard-mod
.It is quite possible that this is not a definite fix for #152.
await hass()
call postpones variable read for a few ticks and this may suffice in my particular case - refreshing page now works in 100% of my cases. YMMV.