feat(app): Désélectionner and the Escape priority (R1, D6, A5, A6)
« Désélectionner » (secondary sm, deselect glyph) sits left of « Supprimer » in a bordered row of the properties panel, read-only too, hidden while a tracing runs. It commits the typed field, clears the selection, focuses the row (else the drawing) and announces. Escape deselects through one document listener per visible body (not in a text field, only inside the workspace); G1: row focus only from the panel. « Plus » and the references panel close first; a tracing cancel marks its Escape. No existing assertion rewritten.
This commit is contained in:
1 parent
7dda61d2ae
commit
bbb1668406
14 files changed
+633
-42
No files matched your search
@@ -8,6 +8,7 @@ import { useAnnotationRequest } from '@/editor/annotations/focusTarget'
|
||||
import { keyboardPending, type NewKind } from '@/editor/annotations/creation'
|
||||
import { parseFrame, type Frame } from '@/editor/annotations/frame'
|
||||
import { isEditable } from '@/editor/annotations/geometryEdit'
|
||||
import { useSelectionEscape } from '@/editor/annotations/deselect'
|
||||
import { usePlacement } from '@/editor/annotations/usePlacement'
|
||||
import {
|
||||
initialUi,
|
||||
@@ -130,10 +131,17 @@ export default function EditableAnnotations(props: Props) {
|
||||
const scene = useScene(props)
|
||||
const context = useCommitContext()
|
||||
const placement = usePlacement({ ...scene, context })
|
||||
const { ui, selected } = scene
|
||||
const visible = usePlaceVisible()
|
||||
const asideRef = useSelectionEscape(
|
||||
selected?.id ?? null,
|
||||
() => scene.dispatch({ type: 'select', id: null }),
|
||||
visible && selected !== undefined && ui.tracing === null && !ui.pending,
|
||||
)
|
||||
return (
|
||||
<div className="grid gap-4 lg:grid-cols-[minmax(0,1fr)_22rem]">
|
||||
<CanvasColumn scene={scene} placement={placement} />
|
||||
<aside>
|
||||
<aside ref={asideRef}>
|
||||
<SidePanel scene={scene} context={context} />
|
||||
</aside>
|
||||
</div>
|
||||
@@ -293,6 +301,7 @@ function SidePanel({
|
||||
context={context}
|
||||
navigate={scene.navigate}
|
||||
onShowAll={() => dispatch({ type: 'select', id: null })}
|
||||
busy={ui.tracing !== null}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
updateGeometry,
|
||||
type CommitContext,
|
||||
} from '@/editor/annotations/annotationCommit'
|
||||
import { useDeselect } from '@/editor/annotations/deselect'
|
||||
import EditorGlyph from '@/components/editor/EditorGlyph'
|
||||
import { isEditable } from '@/editor/annotations/geometryEdit'
|
||||
import type { UiAction } from '@/editor/annotations/uiState'
|
||||
import { geometryErrorsById } from '@/editor/issues'
|
||||
@@ -41,6 +43,8 @@ export interface PropertiesPanelProps {
|
||||
navigate: EditorPlaceProps['navigate']
|
||||
/** Clears the selection: the overview shows again. */
|
||||
onShowAll: () => void
|
||||
/** A tracing runs: the selection is not left from here. */
|
||||
busy?: boolean
|
||||
/** Put before every id, for a twin of the panel that lives beside another one. */
|
||||
idPrefix?: string
|
||||
}
|
||||
@@ -84,7 +88,10 @@ export default function PropertiesPanel(props: PropertiesPanelProps) {
|
||||
/>
|
||||
<GeometrySection {...props} />
|
||||
<StatusActions annotation={annotation} readOnly={readOnly} edit={edit} />
|
||||
<Deletion id={annotation.id} name={name} readOnly={readOnly} />
|
||||
<div className="flex flex-wrap gap-2 border-t border-[var(--color-border)] pt-2.5">
|
||||
<DeselectButton annotationId={annotation.id} {...props} />
|
||||
<Deletion id={annotation.id} name={name} readOnly={readOnly} />
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -107,6 +114,34 @@ function ShowAll({ id, onShowAll }: { id: string; onShowAll: () => void }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** Leaves the annotation open: the overview shows again, the focus on its row. */
|
||||
function DeselectButton({
|
||||
annotationId,
|
||||
onShowAll,
|
||||
busy,
|
||||
}: { annotationId: string } & Pick<
|
||||
PropertiesPanelProps,
|
||||
'onShowAll' | 'busy'
|
||||
>) {
|
||||
const t = useT()
|
||||
const { byButton } = useDeselect(annotationId, onShowAll)
|
||||
if (busy) return null
|
||||
return (
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
className="gap-2"
|
||||
// Keeps the focus in a field being typed, so its blur commit runs in byButton.
|
||||
onMouseDown={(event) => event.preventDefault()}
|
||||
onClick={byButton}
|
||||
>
|
||||
<EditorGlyph name="deselect" size={16} />
|
||||
{t('editor.annotations.deselect')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
function GeometrySection(props: PropertiesPanelProps) {
|
||||
const t = useT()
|
||||
const { annotation, readOnly, geometryLocked } = props
|
||||
|
||||
Reference in new issue
Block a user