diff --git a/src/frontend/src/forms/BomForms.tsx b/src/frontend/src/forms/BomForms.tsx index f5354a5975..c421c0018b 100644 --- a/src/frontend/src/forms/BomForms.tsx +++ b/src/frontend/src/forms/BomForms.tsx @@ -77,7 +77,7 @@ function BomItemSubstituteRow({ type BomItemSubstituteFormProps = { bomItemId: number; - substitutes: any[]; + bomItem: any; onClose?: () => void; }; @@ -88,8 +88,8 @@ export function useEditBomSubstitutesForm(props: BomItemSubstituteFormProps) { const [substitutes, setSubstitutes] = useState([]); useEffect(() => { - setSubstitutes(props.substitutes); - }, [props.substitutes]); + setSubstitutes(props.bomItem?.substitutes ?? []); + }, [props.bomItem.substitutes]); const formFields: ApiFormFieldSet = useMemo(() => { return { diff --git a/src/frontend/src/tables/bom/BomTable.tsx b/src/frontend/src/tables/bom/BomTable.tsx index 140cf78743..0d9686b7c3 100644 --- a/src/frontend/src/tables/bom/BomTable.tsx +++ b/src/frontend/src/tables/bom/BomTable.tsx @@ -428,7 +428,7 @@ export function BomTable({ const editSubstitues = useEditBomSubstitutesForm({ bomItemId: selectedBomItem.pk, - substitutes: selectedBomItem?.substitutes ?? [], + bomItem: selectedBomItem, onClose: () => { table.refreshTable(); } @@ -501,7 +501,9 @@ export function BomTable({ record.validated || !user.hasChangeRole(UserRoles.part), icon: , - onClick: () => validateBomItem(record) + onClick: () => { + validateBomItem(record); + } }, RowEditAction({ hidden: partLocked || !user.hasChangeRole(UserRoles.part),