Skip to content

Commit 5803577

Browse files
committed
fix(composite/list): fix climate schedule not working
1 parent 37587b0 commit 5803577

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/components/features/composite/composite.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ export class Composite extends Component<CompositeProps & WithTranslation<'compo
2727
state: Readonly<CompositeState> = {};
2828
onChange = (endpoint: Endpoint, value: Record<string, unknown>): void => {
2929
const { onChange, feature } = this.props;
30-
if (this.isCompositeRoot()) {
31-
this.setState({ ...this.state, ...value });
32-
} else {
30+
this.setState({ ...this.state, ...value });
31+
if (!this.isCompositeRoot()) {
3332
if (isCompositeFeature(feature)) {
34-
onChange(endpoint, feature.property ? { [feature.property]: value } : value);
33+
onChange(endpoint, feature.property ? { [feature.property]: { ...this.state, ...value } } : value);
3534
} else {
3635
onChange(endpoint, value);
3736
}
@@ -40,7 +39,13 @@ export class Composite extends Component<CompositeProps & WithTranslation<'compo
4039

4140
isCompositeRoot = (): boolean => {
4241
const { parentFeatures } = this.props;
43-
return isCompositeFeature(this.props.feature) && parentFeatures?.length == 1;
42+
return (
43+
isCompositeFeature(this.props.feature) &&
44+
parentFeatures !== undefined &&
45+
(parentFeatures.length === 1 ||
46+
// When parent is e.g. climate
47+
(parentFeatures.length === 2 && ![undefined, 'composite', 'list'].includes(parentFeatures[1].type)))
48+
);
4449
};
4550

4651
onCompositeFeatureApply = (): void => {

src/components/features/list/list.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ class List extends Component<Props, State> {
3939
};
4040

4141
isListRoot = (): boolean => {
42-
return this.props.parentFeatures?.length === 1;
42+
const { parentFeatures } = this.props;
43+
return (
44+
parentFeatures !== undefined &&
45+
(parentFeatures.length === 1 ||
46+
// When parent is e.g. climate
47+
(parentFeatures.length === 2 && ![undefined, 'composite', 'list'].includes(parentFeatures[1].type)))
48+
);
4349
};
4450

4551
render(): JSX.Element | JSX.Element[] {

0 commit comments

Comments
 (0)