diff --git a/CHANGELOG.md b/CHANGELOG.md index 27f83f4..46b8471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. This projec ### Fixed - Browser auto-translation (Chrome, Edge, Safari) is turned off for the web interface, which crashed with a `removeChild` error when the translator rewrote the page. +- Forms: Save is enabled as soon as a field is edited, without leaving the field first, and the Delete, Cancel and Save buttons no longer move when the "Unsaved changes" label appears. ## [2.1.2] - 2026-11-29 diff --git a/src/components/forms/DynamicForm.tsx b/src/components/forms/DynamicForm.tsx index 30c8fe1..a385ebf 100644 --- a/src/components/forms/DynamicForm.tsx +++ b/src/components/forms/DynamicForm.tsx @@ -155,6 +155,7 @@ export function DynamicForm({ const model = useDynamicForm(viewName, objectId, { accountId, fieldOverrides, createValues, showCreatedValues }); const { schema, resolved, mode, isSingleton, state, isDirty, saving, loading, loadError } = model; const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false); + const [pendingInput, setPendingInput] = useState(false); const title = useFormTitle(model); const sectionPrefix = useId(); const wide = useSyncExternalStore(subscribeWide, isWide, () => false); @@ -165,6 +166,7 @@ export function DynamicForm({ const isCreate = mode === 'create'; const readOnly = !isCreate && !canUpdate; const canDelete = !isCreate && !isSingleton && canDestroy; + const hasChanges = isDirty || pendingInput; const subtitle = (model.parentForm ?? model.variantForm)?.subtitle; const errorText = state.generalError ?? loadError; const header = ( @@ -222,7 +224,15 @@ export function DynamicForm({
{showIndex && wide && } -
+
{ + if (!pendingInput && e.target instanceof Node && e.currentTarget.contains(e.target)) setPendingInput(true); + }} + onBlur={() => { + if (pendingInput) setPendingInput(false); + }} + > )} - {isDirty && ( - + {!readOnly && ( + {t('form.unsavedChangesLabel', 'Unsaved changes')} @@ -281,7 +296,7 @@ export function DynamicForm({ size="sm" className="shadow-none" onClick={() => void model.save()} - disabled={saving || (!isCreate && !isDirty)} + disabled={saving || (!isCreate && !hasChanges)} > {saving ? (