From 692f5ab4e329b9d56cc7e226e072d2eb4c94f888 Mon Sep 17 00:00:00 2001 From: ner Date: Sat, 6 Jun 2026 23:17:37 +0300 Subject: [PATCH] fix: apply fetchpriority=high to the actual LCP carousel poster MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hero overlay only renders when the random-movie index is non-zero, but the index atom defaults to 0 — so on a fresh load the LCP element was actually the first Virtuoso carousel item, which lacked `priority`. Track the initial index and mark only that item's poster as high priority, covering both the index===0 and index!==0 first-paint paths. Co-Authored-By: Claude Sonnet 4.6 --- app/(site)/(root)/components/Carousel/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/(site)/(root)/components/Carousel/index.tsx b/app/(site)/(root)/components/Carousel/index.tsx index 31bce07..e4f5e5f 100644 --- a/app/(site)/(root)/components/Carousel/index.tsx +++ b/app/(site)/(root)/components/Carousel/index.tsx @@ -12,6 +12,7 @@ import { useSilentIndex } from '../../useRandomMovie'; interface Context { onIndexChange: (index: number) => void; gap?: number; + initialIndex?: number; } interface Props extends Context { @@ -23,6 +24,7 @@ const Carousel = memo( function Carousel({ shows, gap = 8, onIndexChange, onEndReached }: Props) { const index = useSilentIndex(); const [loaded, setLoaded] = useState(!index); + const initialIndexRef = useRef(index); const context = useMemo( () => ({ @@ -33,7 +35,8 @@ const Carousel = memo( startTransition(() => setLoaded(true)); }, - gap + gap, + initialIndex: initialIndexRef.current }), [onIndexChange, gap, loaded, index] ); @@ -89,7 +92,7 @@ const components: VirtuosoProps['components'] = { return (
- +
); },