feat(app): Aller à selects the element in its tab, reload after submit
This commit is contained in:
1 parent
2a54fa4c78
commit
4f223e04cd
24 files changed
+473
-66
No files matched your search
@@ -4,6 +4,8 @@ import type {
|
||||
Annotation,
|
||||
} from '@faunosteo/core-wasm/types'
|
||||
import type { CommitContext } from '@/editor/annotations/annotationCommit'
|
||||
import { annotationFocus } from '@/editor/annotations/focusTarget'
|
||||
import { useFocusRequest } from '@/editor/focusRequest'
|
||||
import { keyboardPending, type NewKind } from '@/editor/annotations/creation'
|
||||
import { parseFrame, type Frame } from '@/editor/annotations/frame'
|
||||
import { isEditable } from '@/editor/annotations/geometryEdit'
|
||||
@@ -36,6 +38,7 @@ import ViewSwitcher from './ViewSwitcher'
|
||||
interface Props {
|
||||
doc: AnatomicalSheetDocument
|
||||
onSelectTab: EditorTabProps['onSelectTab']
|
||||
focus: EditorTabProps['focus']
|
||||
}
|
||||
|
||||
/** What both columns read: the tab's state, the view, its frame and its selection. */
|
||||
@@ -52,8 +55,14 @@ interface Scene {
|
||||
onSelectTab: EditorTabProps['onSelectTab']
|
||||
}
|
||||
|
||||
function useScene({ doc, onSelectTab }: Props): Scene {
|
||||
function useScene({ doc, onSelectTab, focus }: Props): Scene {
|
||||
const [ui, dispatch] = useReducer(uiReducer, initialUi)
|
||||
useFocusRequest(focus, (key) => {
|
||||
const target = annotationFocus(doc, key)
|
||||
if (!target) return
|
||||
dispatch({ type: 'view', viewId: target.viewId })
|
||||
dispatch({ type: 'select', id: target.annotationId })
|
||||
})
|
||||
const [root, setRoot] = useState<RootAttributes | null>(null)
|
||||
const viewId = ui.viewId ?? mainViewId(doc)
|
||||
const model = useViewModel(doc, viewId)
|
||||
|
||||
Reference in new issue
Block a user