diff --git a/src/components/features/composite/composite.tsx b/src/components/features/composite/composite.tsx index 9e4cd9011..cc81efb8f 100644 --- a/src/components/features/composite/composite.tsx +++ b/src/components/features/composite/composite.tsx @@ -27,11 +27,10 @@ export class Composite extends Component = {}; onChange = (endpoint: Endpoint, value: Record): void => { const { onChange, feature } = this.props; - if (this.isCompositeRoot()) { - this.setState({ ...this.state, ...value }); - } else { + this.setState({ ...this.state, ...value }); + if (!this.isCompositeRoot()) { if (isCompositeFeature(feature)) { - onChange(endpoint, feature.property ? { [feature.property]: value } : value); + onChange(endpoint, feature.property ? { [feature.property]: { ...this.state, ...value } } : value); } else { onChange(endpoint, value); } @@ -40,7 +39,13 @@ export class Composite extends Component { const { parentFeatures } = this.props; - return isCompositeFeature(this.props.feature) && parentFeatures?.length == 1; + return ( + isCompositeFeature(this.props.feature) && + parentFeatures !== undefined && + (parentFeatures.length === 1 || + // When parent is e.g. climate + (parentFeatures.length === 2 && ![undefined, 'composite', 'list'].includes(parentFeatures[1].type))) + ); }; onCompositeFeatureApply = (): void => { diff --git a/src/components/features/list/list.tsx b/src/components/features/list/list.tsx index 160dd83c5..a82510eaa 100644 --- a/src/components/features/list/list.tsx +++ b/src/components/features/list/list.tsx @@ -39,7 +39,13 @@ class List extends Component { }; isListRoot = (): boolean => { - return this.props.parentFeatures?.length === 1; + const { parentFeatures } = this.props; + return ( + parentFeatures !== undefined && + (parentFeatures.length === 1 || + // When parent is e.g. climate + (parentFeatures.length === 2 && ![undefined, 'composite', 'list'].includes(parentFeatures[1].type))) + ); }; render(): JSX.Element | JSX.Element[] {