Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions components/album/preview-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ export default function PreviewImage(props: Readonly<PreviewImageHandleProps>) {
// limit — on top of the ±loadRadius unmount that already bounds them.
const VIEWER_LRU_CAP = 3
const [zoomLru, setZoomLru] = useState<string[]>([])
const bumpZoomLru = useCallback((id: string) => {
const bumpZoomLru = useCallback((id: string | undefined) => {
if (!id) return
setZoomLru((prev) => [id, ...prev.filter((x) => x !== id)].slice(0, VIEWER_LRU_CAP))
}, [])
// Exit transition: fade the detail view out, then navigate (deferred-nav), so
Expand Down Expand Up @@ -441,7 +442,7 @@ export default function PreviewImage(props: Readonly<PreviewImageHandleProps>) {
imageKey={photo.image_key}
readyMaxWidth={photo.ready_max_width}
variantBaseUrl={configData?.variantBaseUrl ?? ''}
keepViewerMounted={zoomLru.includes(photo.id)}
keepViewerMounted={zoomLru.includes(photo.id) || (isCurrent && lightboxPhoto)}
showLightbox={isCurrent && lightboxPhoto}
onShowLightboxChange={isCurrent ? ((value) => { setLightboxPhoto(value); if (value) bumpZoomLru(photo.id) }) : undefined}
/>
Expand Down Expand Up @@ -604,6 +605,9 @@ export default function PreviewImage(props: Readonly<PreviewImageHandleProps>) {
className="inline-flex items-center justify-center cursor-pointer"
onClick={() => {
setLightboxPhoto(true)
// Mirror the image-click path: register the viewer in the LRU so
// the mount-gate (keepViewerMounted) actually mounts it.
bumpZoomLru(current?.id)
}}
{...mergeAnimatedTriggerProps({}, triggerProps)}
>
Expand Down
Loading