Fix card flashing icon-only on load - #339
Merged
Merged
Conversation
The card renders inside ha-card, which is not defined yet on first update. An undefined ha-card has no shadow root and so no slot, leaving its children unslotted with a zero layout box, so measureCard() fell back to icon only. Skip slides that are not laid out yet, and re-measure on every update. Also replace the 250ms debounce on the resize observer with a synchronous measure, so the headline no longer visibly swaps after Home Assistant reflows the masonry columns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #338
On first update the card's content sits inside
ha-cardbefore it has rendered its slot, so the slides have no layout box and measure 0 wide.measureCard()read that as "nothing fits" and collapsed the card to icon only, until a debounced resize observer corrected it a quarter of a second later.Slides that are not laid out yet are now skipped, and the card re-measures on every update. Dropping the 250ms debounce also stops the headline swapping a moment after Home Assistant reflows the masonry columns.
Before
blink-after.mp4
After
blink-before.mp4