fix(app): a focus request is consumed once, not replayed on tab return
This commit is contained in:
1 parent
4f223e04cd
commit
3d589e1556
14 files changed
+99
-30
No files matched your search
@@ -5,7 +5,6 @@ import type {
|
||||
} 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'
|
||||
@@ -23,6 +22,7 @@ import {
|
||||
useViewModel,
|
||||
type ViewModel,
|
||||
} from '@/editor/annotations/useViewModel'
|
||||
import { useFocusRequest } from '@/editor/focusRequest'
|
||||
import type { EditorTabProps } from '@/editor/tabs'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { FOCUS_CLASS, focusAttrs } from '@/editor/focusRequest'
|
||||
import { useState } from 'react'
|
||||
import type {
|
||||
AnatomicalSheetDocument,
|
||||
@@ -10,12 +9,15 @@ import TextField from '@/components/editor/fields/TextField'
|
||||
import DeleteDialog, {
|
||||
type DeleteTarget,
|
||||
} from '@/components/editor/DeleteDialog'
|
||||
import { FOCUS_CLASS, focusAttrs } from '@/editor/focusRequest'
|
||||
import { isBlank, nullable } from '@/editor/sheetDocument'
|
||||
import { useEditCommand } from '@/editor/useEditCommand'
|
||||
import type { Locale } from '@/i18n/types'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
|
||||
const CARD = 'rounded-lg border border-[var(--color-border)] p-3'
|
||||
|
||||
/** Annotation categories: list, rename, colour, add, delete with dependents. */
|
||||
export default function CategoriesSection({
|
||||
doc,
|
||||
@@ -78,7 +80,7 @@ function CategoryRow({
|
||||
return (
|
||||
<li
|
||||
{...focusAttrs({ kind: 'category', id: category.id })}
|
||||
className={`rounded-lg border border-[var(--color-border)] p-3 ${FOCUS_CLASS}`}
|
||||
className={`${CARD} ${FOCUS_CLASS}`}
|
||||
>
|
||||
<div className="grid gap-3 md:grid-cols-3">
|
||||
{(['fr', 'en'] as const).map((locale) => (
|
||||
|
||||
@@ -9,6 +9,8 @@ import { useEditCommand } from '@/editor/useEditCommand'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { REFERENCE_TYPES } from './referenceTypes'
|
||||
|
||||
const CARD = 'space-y-3 rounded-lg border border-[var(--color-border)] p-3'
|
||||
|
||||
/** One reference: fields commit one by one, ↑ / ↓ reorder, delete asks the core. */
|
||||
export default function ReferenceRow({
|
||||
reference,
|
||||
@@ -38,10 +40,7 @@ export default function ReferenceRow({
|
||||
}))
|
||||
const prefix = `reference-${reference.id}`
|
||||
return (
|
||||
<li
|
||||
{...focusAttrs(key)}
|
||||
className={`space-y-3 rounded-lg border border-[var(--color-border)] p-3 ${FOCUS_CLASS}`}
|
||||
>
|
||||
<li {...focusAttrs(key)} className={`${CARD} ${FOCUS_CLASS}`}>
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
<SelectField
|
||||
id={`${prefix}-type`}
|
||||
|
||||
@@ -9,8 +9,8 @@ import PropertiesPanel from '@/components/editor/annotations/PropertiesPanel'
|
||||
import ViewSwitcher from '@/components/editor/annotations/ViewSwitcher'
|
||||
import SelectionTag from '@/components/editor/annotations/SelectionTag'
|
||||
import { annotationFocus } from '@/editor/annotations/focusTarget'
|
||||
import { useFocusRequest } from '@/editor/focusRequest'
|
||||
import { mainViewId, useViewModel } from '@/editor/annotations/useViewModel'
|
||||
import { useFocusRequest } from '@/editor/focusRequest'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import { useEditorStore } from '@/editor/state/editorStore'
|
||||
import type { EditorTabProps } from '@/editor/tabs'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import AttributionSection from '@/components/editor/general/AttributionSection'
|
||||
import CategoriesSection from '@/components/editor/general/CategoriesSection'
|
||||
import TextsSection from '@/components/editor/general/TextsSection'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import { useRowFocus } from '@/editor/focusRequest'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import type { EditorTabProps } from '@/editor/tabs'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import DeleteDialog, {
|
||||
} from '@/components/editor/DeleteDialog'
|
||||
import ReferenceForm from '@/components/editor/references/ReferenceForm'
|
||||
import ReferenceRow from '@/components/editor/references/ReferenceRow'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import { useRowFocus } from '@/editor/focusRequest'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import type { EditorTabProps } from '@/editor/tabs'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import DeleteDialog, {
|
||||
} from '@/components/editor/DeleteDialog'
|
||||
import RegionForm from '@/components/editor/vertebrae/RegionForm'
|
||||
import RegionRow from '@/components/editor/vertebrae/RegionRow'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import { useRowFocus } from '@/editor/focusRequest'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import type { EditorTabProps } from '@/editor/tabs'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
|
||||
@@ -5,8 +5,8 @@ import DeleteDialog, {
|
||||
import DetailViewForm from '@/components/editor/views/DetailViewForm'
|
||||
import DetailViewRow from '@/components/editor/views/DetailViewRow'
|
||||
import MainViewCard from '@/components/editor/views/MainViewCard'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import { useRowFocus } from '@/editor/focusRequest'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import type { EditorTabProps } from '@/editor/tabs'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { FOCUS_CLASS, focusAttrs } from '@/editor/focusRequest'
|
||||
import { useState } from 'react'
|
||||
import type { VertebralRegion } from '@faunosteo/core-wasm/types'
|
||||
import ActionButton from '@/components/editor/fields/ActionButton'
|
||||
import MoveButtons from '@/components/editor/fields/MoveButtons'
|
||||
import ReadOnlyValue from '@/components/editor/fields/ReadOnlyValue'
|
||||
import TextField from '@/components/editor/fields/TextField'
|
||||
import { FOCUS_CLASS, focusAttrs } from '@/editor/focusRequest'
|
||||
import { isBlank } from '@/editor/sheetDocument'
|
||||
import { useEditCommand } from '@/editor/useEditCommand'
|
||||
import type { Locale } from '@/i18n/types'
|
||||
@@ -12,6 +12,8 @@ import { useT } from '@/i18n/useT'
|
||||
import RangeFields from './RangeFields'
|
||||
import { parseRange, wholeNumber } from './numbers'
|
||||
|
||||
const CARD = 'space-y-3 rounded-lg border border-[var(--color-border)] p-3'
|
||||
|
||||
const textOf = (value: number | undefined): string =>
|
||||
value === undefined ? '' : String(value)
|
||||
|
||||
@@ -52,7 +54,7 @@ export default function RegionRow({
|
||||
return (
|
||||
<li
|
||||
{...focusAttrs({ kind: 'region', code: region.code })}
|
||||
className={`space-y-3 rounded-lg border border-[var(--color-border)] p-3 ${FOCUS_CLASS}`}
|
||||
className={`${CARD} ${FOCUS_CLASS}`}
|
||||
>
|
||||
<div className="grid gap-3 md:grid-cols-4">
|
||||
<ReadOnlyValue
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FOCUS_CLASS, focusAttrs } from '@/editor/focusRequest'
|
||||
import type { DetailView, SheetView } from '@faunosteo/core-wasm/types'
|
||||
import ActionButton from '@/components/editor/fields/ActionButton'
|
||||
import SelectField from '@/components/editor/fields/SelectField'
|
||||
import { FOCUS_CLASS, focusAttrs } from '@/editor/focusRequest'
|
||||
import { useViewUpdate } from '@/editor/useViewUpdate'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
@@ -9,6 +9,8 @@ import CropEditor from './CropEditor'
|
||||
import ViewDrawing from './ViewDrawing'
|
||||
import ViewNames from './ViewNames'
|
||||
|
||||
const CARD = 'space-y-3 rounded-lg border border-[var(--color-border)] p-3'
|
||||
|
||||
/** One detail view: names, parent, own drawing, crop (one crop canvas open at a time). */
|
||||
export default function DetailViewRow({
|
||||
view,
|
||||
@@ -38,7 +40,7 @@ export default function DetailViewRow({
|
||||
<li
|
||||
aria-label={view.name[locale]}
|
||||
{...focusAttrs({ kind: 'view', id: view.id })}
|
||||
className={`space-y-3 rounded-lg border border-[var(--color-border)] p-3 ${FOCUS_CLASS}`}
|
||||
className={`${CARD} ${FOCUS_CLASS}`}
|
||||
>
|
||||
<div className="grid gap-3 md:grid-cols-3">
|
||||
<ViewNames view={view} readOnly={readOnly} views={edit} />
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { FOCUS_CLASS, focusAttrs } from '@/editor/focusRequest'
|
||||
import type { MainView } from '@faunosteo/core-wasm/types'
|
||||
import { FOCUS_CLASS, focusAttrs } from '@/editor/focusRequest'
|
||||
import { useViewUpdate } from '@/editor/useViewUpdate'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import ViewDrawing from './ViewDrawing'
|
||||
import ViewNames from './ViewNames'
|
||||
|
||||
const CARD = 'space-y-3 rounded-lg border border-[var(--color-border)] p-3'
|
||||
|
||||
/** The main view: its names and its drawing (state, detail, « Choisir une illustration »). */
|
||||
export default function MainViewCard({
|
||||
view,
|
||||
@@ -19,7 +21,7 @@ export default function MainViewCard({
|
||||
<section
|
||||
aria-labelledby="views-main-title"
|
||||
{...focusAttrs({ kind: 'view', id: view.id })}
|
||||
className={`space-y-3 rounded-lg border border-[var(--color-border)] p-3 ${FOCUS_CLASS}`}
|
||||
className={`${CARD} ${FOCUS_CLASS}`}
|
||||
>
|
||||
<h3 id="views-main-title" className="text-base font-semibold">
|
||||
{t('editor.views.main_title')}
|
||||
|
||||
Reference in new issue
Block a user