From 938863425bf8ad6c17e43b3da128f92cf6d6ab63 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 21 Feb 2026 09:26:44 +0900 Subject: fix(frontend): prevent layout shift in feed sidebar during loading Show "All feeds" button immediately and load individual feeds asynchronously via internal Suspense boundary, avoiding the spinner-to-content shift that occurred with the outer Suspense wrapper. Co-Authored-By: Claude Opus 4.6 --- frontend/src/components/FeedSidebar.tsx | 78 ++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 26 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/FeedSidebar.tsx b/frontend/src/components/FeedSidebar.tsx index 209be23..3a367f5 100644 --- a/frontend/src/components/FeedSidebar.tsx +++ b/frontend/src/components/FeedSidebar.tsx @@ -1,6 +1,8 @@ import { useAtomValue } from "jotai"; +import { Suspense } from "react"; import { useLocation, useSearch } from "wouter"; import { feedsAtom } from "../atoms"; +import { ErrorBoundary } from "./ErrorBoundary"; interface Props { basePath: string; @@ -13,12 +15,6 @@ export function FeedSidebar({ basePath, isReadView = false }: Props) { const params = new URLSearchParams(search); const selectedFeedId = params.get("feed"); - const { data: allFeeds } = useAtomValue(feedsAtom); - - const feeds = isReadView - ? allFeeds - : allFeeds.filter((feed) => feed.unreadCount > 0); - const handleSelect = (feedId: string | null) => { if (feedId) { setLocation(`${basePath}?feed=${feedId}`); @@ -46,27 +42,57 @@ export function FeedSidebar({ basePath, isReadView = false }: Props) { All feeds - {feeds.map((feed) => ( -
  • - -
  • - ))} + + + + + ); } + +function FeedListItems({ + isReadView, + selectedFeedId, + onSelect, +}: { + isReadView: boolean; + selectedFeedId: string | null; + onSelect: (feedId: string | null) => void; +}) { + const { data: allFeeds } = useAtomValue(feedsAtom); + + const feeds = isReadView + ? allFeeds + : allFeeds.filter((feed) => feed.unreadCount > 0); + + return ( + <> + {feeds.map((feed) => ( +
  • + +
  • + ))} + + ); +} -- cgit v1.3-1-g0d28