fix(editor): forget the citing form on Back, refuse sparse paths
This commit is contained in:
1 parent
7a5684aace
commit
6c0f913104
5 files changed
+30
-3
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useRef, useState } from 'react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import type { ElementKey } from '@faunosteo/core-wasm/types'
|
||||
import type { NavigationState } from './navigation'
|
||||
import type { LayerContext, MoveTrace } from './useEditorNavigation'
|
||||
|
||||
/** The reference a creation just made: the library shows a notice for it, once per serial. */
|
||||
@@ -169,8 +170,14 @@ function useFilter(ctx: LayerContext, trace: MoveTrace) {
|
||||
export function useReferenceMoves(
|
||||
ctx: LayerContext,
|
||||
trace: MoveTrace,
|
||||
view: NavigationState['reference'],
|
||||
): ReferenceMoves {
|
||||
const held = useRef<Held>({ opener: null, cite: null }).current
|
||||
const creating = view !== null && 'create' in view
|
||||
// A Back that removes the creation dialog leaves no citing form to answer.
|
||||
useEffect(() => {
|
||||
if (!creating) held.cite = null
|
||||
}, [creating, held])
|
||||
const opener = useCallback((): HTMLElement | null => {
|
||||
const element = held.opener
|
||||
return element?.isConnected && !element.closest('[hidden]') ? element : null
|
||||
|
||||
Reference in new issue
Block a user