Fix Lovelace view background flicker when switching between views with identical backgrounds#51371
Open
tw-zs wants to merge 3 commits intohome-assistant:devfrom
Open
Fix Lovelace view background flicker when switching between views with identical backgrounds#51371tw-zs wants to merge 3 commits intohome-assistant:devfrom
tw-zs wants to merge 3 commits intohome-assistant:devfrom
Conversation
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
…-container This change moves the hui-view-background component outside of hui-view-container so it is not removed when switching views. Previously, hui-view-background was a child of hui-view-container and was being recreated on every view switch, causing a white/black flash when switching between views with backgrounds. Changes: - Move hui-view-background to be a sibling of hui-view-container - Add fixed positioning CSS for hui-view-background - Simplify component styles to remove redundant positioning - Add CSS transition for smooth background changes Fixes home-assistant#51300
piitaya
reviewed
Apr 9, 2026
Member
There was a problem hiding this comment.
Hi 👋
The background element is now always position: fixed (set by the parent), whereas before it used position: absolute for non-fixed backgrounds and position: fixed only for fixed ones (Safari iOS hack : #22531).
I tested and the scroll behavior is broken (even in chrome) when using attachment: scroll
Comment on lines
+1494
to
+1501
| hui-view-background { | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| z-index: -1; | ||
| } |
Member
There was a problem hiding this comment.
The background is always fixed now. This means attachment: scroll doesn't work anymore.
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.
Proposed change
This PR fixes an issue where switching between views with background images causes the background to flicker/flash white or black.
The flicker occurs because:
<hui-view-background>component was a child of<hui-view-container>and was being removed/recreated on every view switch_fetchMedia()was being called unnecessarilyThis PR addresses both issues:
Fix 1: Move hui-view-background outside hui-view-container
The
<hui-view-background>component is now a sibling of<hui-view-container>instead of a child. This prevents it from being removed when switching views, eliminating the flicker caused by component recreation.Fix 2: Cache resolved media sources and skip unnecessary updates
mediaSourceUrlCacheto cache resolved media source URLs_currentMediaContentIdto track the currently loaded image_pendingMediaContentIdto track in-flight media resolutiondeepEqualcomparison to skip updates when background config is unchangedType of change
Additional information
Checklist