diff --git a/src/components/Dashboard/common/ObjectChildTable.jsx b/src/components/Dashboard/common/ObjectChildTable.jsx index 6269136..6c9d898 100644 --- a/src/components/Dashboard/common/ObjectChildTable.jsx +++ b/src/components/Dashboard/common/ObjectChildTable.jsx @@ -47,6 +47,7 @@ const createSkeletonRows = (rowCount, keyPrefix, keyName) => { const ObjectChildTable = ({ maxWidth = '100%', + name, properties = [], columns = [], visibleColumns = {}, @@ -264,6 +265,17 @@ const ObjectChildTable = ({ const rollupDataSource = useMemo(() => { if (!rollups || rollups.length === 0) return [] + // Use value from form/props, or fall back to objectData when entering edit mode + // (form may not have populated the field yet) + const itemsForRollup = + value ?? (name && objectData ? objectData[name] : null) ?? [] + + // Build parent object with children array for rollup functions (e.g. objectData.parts) + const updatedObjectData = { ...objectData } + if (name) { + updatedObjectData[name] = itemsForRollup + } + // Single summary row where each rollup value is placed under // the column that matches its `property` field. const summaryRow = {} @@ -275,8 +287,6 @@ const ObjectChildTable = ({ if (rollup && typeof rollup.value === 'function') { try { - const updatedObjectData = { ...objectData } - updatedObjectData[property.name] = value summaryRow[property.name] = rollup.value(updatedObjectData) } catch (e) { // Fail quietly but log for debugging @@ -289,7 +299,7 @@ const ObjectChildTable = ({ }) return [summaryRow] - }, [properties, rollups, objectData, value]) + }, [properties, rollups, objectData, value, name]) const rollupColumns = useMemo(() => { const propertyColumns = properties.map((property, index) => { @@ -455,6 +465,7 @@ const ObjectChildTable = ({ } ObjectChildTable.propTypes = { + name: PropTypes.string, properties: PropTypes.arrayOf( PropTypes.shape({ name: PropTypes.string.isRequired, diff --git a/src/components/Dashboard/common/ObjectProperty.jsx b/src/components/Dashboard/common/ObjectProperty.jsx index e1e3f93..e63072c 100644 --- a/src/components/Dashboard/common/ObjectProperty.jsx +++ b/src/components/Dashboard/common/ObjectProperty.jsx @@ -407,6 +407,7 @@ const ObjectProperty = ({ case 'objectChildren': { return (