From 753115146c05b0b2a9b945197e145db64a35b841 Mon Sep 17 00:00:00 2001 From: John Swanke Date: Mon, 24 Aug 2026 12:10:52 -0400 Subject: [PATCH 1/2] fix(wizards): expand newly added array item even when defaultCollapsed WizArrayInput applied the same defaultCollapsed value to every row, including one just added via the "Add" button, so a new label expression added while editing an existing ApplicationSet mounted collapsed and looked like nothing had been added. Track the index of the most recently added item and force only that row to render expanded. Signed-off-by: John Swanke Co-authored-by: Cursor --- .../src/inputs/WizArrayInput.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/packages/react-form-wizard/src/inputs/WizArrayInput.tsx b/frontend/packages/react-form-wizard/src/inputs/WizArrayInput.tsx index afb938e1bcb..d16e81586b5 100644 --- a/frontend/packages/react-form-wizard/src/inputs/WizArrayInput.tsx +++ b/frontend/packages/react-form-wizard/src/inputs/WizArrayInput.tsx @@ -21,6 +21,7 @@ import { forwardRef, useCallback, useContext, + useEffect, useLayoutEffect, useMemo, useRef, @@ -82,24 +83,40 @@ export function WizArrayInput(props: WizArrayInputProps) { const item = useContext(ItemContext) const values = wizardArrayItems(props, item) + // Tracks the index of the item most recently added via addItem, so it can be + // rendered expanded even when defaultCollapsed collapses pre-existing rows. + const [addedIndex, setAddedIndex] = useState(null) + const addItem = useCallback( (newItem: object | object[]) => { if (path === null) { ;(item as any[]).push(newItem) + setAddedIndex((item as any[]).length - 1) } else { let newArray = values + let newIndex = newArray.length if (Array.isArray(newItem)) { newArray = [...newArray, ...newItem] + newIndex = newArray.length - newItem.length } else { newArray.push(newItem as never) } setValue(newArray) + setAddedIndex(newIndex) } update() }, [item, path, setValue, update, values] ) + // Clear the added-item marker once it has been used for the initial mount of the + // corresponding ArrayInputItem; later add/remove actions won't re-expand this index. + useEffect(() => { + if (addedIndex !== null) { + setAddedIndex(null) + } + }, [addedIndex]) + if (!values.length && props.disallowEmpty) { addItem(props.newValue ?? {}) } @@ -195,7 +212,7 @@ export function WizArrayInput(props: WizArrayInputProps) { moveUp={moveUp} moveDown={moveDown} removeItem={removeItem} - defaultExpanded={!props.defaultCollapsed} + defaultExpanded={index === addedIndex ? true : !props.defaultCollapsed} hideFromReviewStep={props.hideFromReviewStep} > {props.children} From 576579f8ac1cb0a0adffa26784b5a53d1d7a4382 Mon Sep 17 00:00:00 2001 From: John Swanke Date: Mon, 24 Aug 2026 13:06:36 -0400 Subject: [PATCH 2/2] rabbit stew Signed-off-by: John Swanke --- .../react-form-wizard/src/inputs/WizArrayInput.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/packages/react-form-wizard/src/inputs/WizArrayInput.tsx b/frontend/packages/react-form-wizard/src/inputs/WizArrayInput.tsx index d16e81586b5..03f874d10fa 100644 --- a/frontend/packages/react-form-wizard/src/inputs/WizArrayInput.tsx +++ b/frontend/packages/react-form-wizard/src/inputs/WizArrayInput.tsx @@ -78,6 +78,7 @@ export function WizArrayInput(props: WizArrayInputProps) { const onToggle = useCallback(() => setOpen((open: boolean) => !open), []) const path = props.path + const filter = props.filter const { update } = useData() const item = useContext(ItemContext) @@ -90,8 +91,15 @@ export function WizArrayInput(props: WizArrayInputProps) { const addItem = useCallback( (newItem: object | object[]) => { if (path === null) { - ;(item as any[]).push(newItem) - setAddedIndex((item as any[]).length - 1) + const rawArray = item as any[] + rawArray.push(newItem) + if (filter && !filter(newItem)) { + // The added item won't be rendered at all, so there's no row to expand. + setAddedIndex(null) + } else { + const renderedArray = filter ? rawArray.filter(filter) : rawArray + setAddedIndex(renderedArray.length - 1) + } } else { let newArray = values let newIndex = newArray.length @@ -106,7 +114,7 @@ export function WizArrayInput(props: WizArrayInputProps) { } update() }, - [item, path, setValue, update, values] + [filter, item, path, setValue, update, values] ) // Clear the added-item marker once it has been used for the initial mount of the