diff options
Diffstat (limited to 'src/state/lightbox.tsx')
-rw-r--r-- | src/state/lightbox.tsx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/state/lightbox.tsx b/src/state/lightbox.tsx index 67a450991..3e01d7ef7 100644 --- a/src/state/lightbox.tsx +++ b/src/state/lightbox.tsx @@ -31,7 +31,15 @@ export function Provider({children}: React.PropsWithChildren<{}>) { const openLightbox = useNonReactiveCallback( (lightbox: Omit<Lightbox, 'id'>) => { - setActiveLightbox({...lightbox, id: nanoid()}) + setActiveLightbox(prevLightbox => { + if (prevLightbox) { + // Ignore duplicate open requests. If it's already open, + // the user has to explicitly close the previous one first. + return prevLightbox + } else { + return {...lightbox, id: nanoid()} + } + }) }, ) |