-
-
Notifications
You must be signed in to change notification settings - Fork 202
Perf: Optimize CountryFlag to Prevent Grid Reflows #9053
Copy link
Copy link
Closed
Labels
aibugSomething isn't workingSomething isn't workingperformancePerformance improvements and optimizationsPerformance improvements and optimizations
Description
The Neo.component.CountryFlag component has been identified as the source of "Forced Reflow" violations during Grid scrolling.
The current implementation switches the VDOM tag between img and span depending on whether a flag URL is available. This triggers frequent node removal/insertion during scrolling, which, combined with the lack of explicit dimension attributes on the img tag, causes layout thrashing.
Optimization Strategy:
- CSS Containment: Apply
contain: strictto.neo-country-flag(the container) to isolate layout calculations. - Stable VDOM Structure: Instead of swapping tags (
img<->span), maintain a stable DOM structure to avoidremoveNode/insertNodeoperations.- Proposed Structure: Always render an
imgtag. If no flag is available, setsrcto a transparent pixel (or handle via CSS visibility) and potentially toggle a class like.neo-country-placeholder.
- Proposed Structure: Always render an
- Explicit Dimensions: Add
width="20"andheight="20"attributes to theimgVDOM node to prevent layout shifts during image loading.
Implementation Steps:
- Modify
resources/scss/src/component/CountryFlag.scss: Addcontain: strictto the main wrapper. - Modify
src/component/CountryFlag.mjs:- Refactor
afterSetLocationto maintain a stableimgtag. - Add explicit
widthandheightattributes to theimgconfig. - Handle the "no flag" state by hiding the image or using a placeholder source, avoiding tag replacement.
- Refactor
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
aibugSomething isn't workingSomething isn't workingperformancePerformance improvements and optimizationsPerformance improvements and optimizations