広場投稿追加画面の刷新 (#399) #413

マージ済み
みてるぞ が 103 個のコミットを feature/399 から main へマージ 2026-07-19 00:03:11 +09:00
コミット 206c6bc0a0 の変更だけを表示してゐます - すべてのコミットを表示
+10 -7
ファイルの表示
@@ -35,7 +35,7 @@ const UnsavedChangesGuardContext =
export const UnsavedChangesGuardProvider: FC<PropsWithChildren> = ({ children }) => { export const UnsavedChangesGuardProvider: FC<PropsWithChildren> = ({ children }) => {
const dialogue = useDialogue () const dialogue = useDialogue ()
const sourcesRef = useRef (new Map<symbol, UnsavedChangesSource> ()) const sourcesRef = useRef (new Map<symbol, UnsavedChangesSource> ())
const bypassNextNavigationRef = useRef (false) const bypassNextNavigationRef = useRef<symbol | null> (null)
const [revision, setRevision] = useState (0) const [revision, setRevision] = useState (0)
const dialogueOpenRef = useRef (false) const dialogueOpenRef = useRef (false)
@@ -55,7 +55,13 @@ export const UnsavedChangesGuardProvider: FC<PropsWithChildren> = ({ children })
}, []) }, [])
const allowNextNavigation = useCallback (() => { const allowNextNavigation = useCallback (() => {
bypassNextNavigationRef.current = true const token = Symbol ('allowed-navigation')
bypassNextNavigationRef.current = token
queueMicrotask (() => {
if (bypassNextNavigationRef.current === token)
bypassNextNavigationRef.current = null
})
}, []) }, [])
const sources = useMemo ( const sources = useMemo (
@@ -68,16 +74,13 @@ export const UnsavedChangesGuardProvider: FC<PropsWithChildren> = ({ children })
) )
const hasUnsavedChanges = dirtySources.length > 0 const hasUnsavedChanges = dirtySources.length > 0
const shouldBlock = useCallback (() => { const shouldBlock = useCallback (() => {
if (!(hasUnsavedChanges)) if (bypassNextNavigationRef.current != null)
return false
if (bypassNextNavigationRef.current)
{ {
bypassNextNavigationRef.current = false bypassNextNavigationRef.current = false
return false return false
} }
return true return hasUnsavedChanges
}, [hasUnsavedChanges]) }, [hasUnsavedChanges])
const blocker = useBlocker (shouldBlock) const blocker = useBlocker (shouldBlock)