diff --git a/packages/design/src/FormManager/FormEdit/components/PreviewSequencePattern/index.tsx b/packages/design/src/FormManager/FormEdit/components/PreviewSequencePattern/index.tsx index 0f7d0405..6dfe7144 100644 --- a/packages/design/src/FormManager/FormEdit/components/PreviewSequencePattern/index.tsx +++ b/packages/design/src/FormManager/FormEdit/components/PreviewSequencePattern/index.tsx @@ -8,6 +8,7 @@ import { PatternEditComponent } from '../../types'; // TODO: consider merging this component with DraggableList, to clean up // sematics around how its children are handled. +// Counterpoint: it's nice to have state management separate from DraggableList. export const PatternPreviewSequence: PatternEditComponent< SequenceProps > = props => { diff --git a/packages/forms/src/builder/builder.test.ts b/packages/forms/src/builder/builder.test.ts index e15c80aa..96f4037b 100644 --- a/packages/forms/src/builder/builder.test.ts +++ b/packages/forms/src/builder/builder.test.ts @@ -17,15 +17,15 @@ describe('form builder', () => { it('addPattern preserves existing structure', () => { const initial = createTestBlueprint(); - const newBuilder = new BlueprintBuilder(defaultFormConfig, initial); - const newPattern = newBuilder.addPatternToPage('input'); - expect(newBuilder.form.patterns[newPattern.id]).toEqual(newPattern); + const builder = new BlueprintBuilder(defaultFormConfig, initial); + const newPattern = builder.addPatternToPage('input'); + expect(builder.form.patterns[newPattern.id]).toEqual(newPattern); const oldPage = getPattern(initial, 'page-1'); - const newPage = getPattern(newBuilder.form, 'page-1'); - expect(newPage.data.patterns).toEqual([ - ...oldPage.data.patterns, - newPattern.id, - ]); + const newPage = getPattern(builder.form, 'page-1'); + expect(newPage.data).toEqual({ + ...oldPage.data, + patterns: [...oldPage.data.patterns, newPattern.id], + }); }); it('removePattern removes pattern and sequence reference', () => { diff --git a/packages/forms/src/index.ts b/packages/forms/src/index.ts index b2027016..68edf48e 100644 --- a/packages/forms/src/index.ts +++ b/packages/forms/src/index.ts @@ -203,6 +203,7 @@ export const addPatternToPage = ( [pagePattern.id]: { ...pagePattern, data: { + ...pagePattern.data, patterns: [...pagePattern.data.patterns, pattern.id], }, } satisfies SequencePattern,