From 532aba026a89d6bc14293c274feb9c0fd5c6eb23 Mon Sep 17 00:00:00 2001 From: lyzno1 Date: Wed, 10 Sep 2025 23:56:22 +0800 Subject: [PATCH] fix: filter empty URLs in image gallery to prevent browser reload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add validation to filter out empty and whitespace-only image URLs - Return null when no valid images exist - Prevents console errors and browser reload issues from empty img src 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- app/components/base/image-gallery/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/components/base/image-gallery/index.tsx b/app/components/base/image-gallery/index.tsx index bd46c34..0d078e2 100644 --- a/app/components/base/image-gallery/index.tsx +++ b/app/components/base/image-gallery/index.tsx @@ -32,12 +32,15 @@ const ImageGallery: FC = ({ }) => { const [imagePreviewUrl, setImagePreviewUrl] = useState('') - const imgNum = srcs.length + const validSrcs = srcs.filter(src => src && src.trim() !== '') + const imgNum = validSrcs.length const imgStyle = getWidthStyle(imgNum) + + if (imgNum === 0) { return null } + return (
- {/* TODO: support preview */} - {srcs.map((src, index) => ( + {validSrcs.map((src, index) => (