feat(editor): keep edit-only forms across a width change

Edit-only parts (creation forms, submission note, crop group, annotation
edit body) mount at the first editable render and stay mounted, hidden
and detached from canvases, while read-only. Guards: the viewport hook
commits the focused field before the tier crosses 1 024 px, the route
releases focus left in a hidden part and treats a store out of step as
read-only, delete and discard confirmations close when the editor turns
read-only, a drag is dropped while the edit body is hidden. Read-only
twins take an id prefix.

R-24: no existing assertion rewritten; editor-no-loss.test.tsx and two
editor-shell Chromium cases added.
This commit is contained in:
bchanot committed 2026-11-06 21:22:10 +01:00
1 parent 9d89daed19
commit c57af6441f
23 files changed
+883 -108

No files matched your search

@@ -23,6 +23,7 @@ import {
type ViewModel,
} from '@/editor/annotations/useViewModel'
import type { AnnotationSection } from '@/editor/navigation'
import { usePlaceVisible } from '@/lib/placeVisibility'
import type { EditorPlaceProps } from '@/editor/tabs'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
@@ -213,6 +214,8 @@ function CanvasStage({
placement: Placement
}) {
const locale = useLocaleStore((s) => s.locale)
// Hidden (the editor is read-only): no drag in flight survives, none is committed.
const shown = usePlaceVisible()
const { doc, ui, dispatch, model, frame, selected } = scene
const view = doc.views.find((v) => v.id === scene.viewId)
const blocked = !model.measured || doc.categories.length === 0
@@ -223,7 +226,7 @@ function CanvasStage({
viewName={view.name[locale]}
tool={ui.tool}
selectedId={ui.selectedId}
moveTarget={moveTargetOf(selected, model, ui.tool)}
moveTarget={shown ? moveTargetOf(selected, model, ui.tool) : null}
overlay={overlayOf(ui, selected, frame)}
tools={{
tool: ui.tool,