fix: prevent backdrop flash on close by not resetting isClosing before navigation

setIsClosing(false) ran before closeViewer() navigated away, which
momentarily set isOpen back to true (URL still had the photoId),
causing the backdrop to flash for one frame. Now we only reset
isClosing in the cancelled-close branch; the active-close branch
navigates directly and lets the component unmount.

https://claude.ai/code/session_01GE9xCcB59MnZiERpgBXxo8
This commit is contained in:
Claude
2026-03-29 12:58:25 +00:00
parent 9188b871bc
commit c076b2251f

View File

@@ -47,10 +47,14 @@ export const Component = () => {
}, [])
const handleExitComplete = useCallback(() => {
setIsClosing(false)
if (isCloseActiveRef.current) {
isCloseActiveRef.current = false
// Navigate away — the component unmounts so no need to reset isClosing.
// Resetting it before navigation would momentarily flip isOpen back to true
// (the URL still has the photoId), causing the backdrop to flash.
closeViewerRef.current()
} else {
setIsClosing(false)
}
}, [])