Skip to content

Commit

Permalink
fix(composite/list): fix climate schedule not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Nov 9, 2023
1 parent 37587b0 commit 5803577
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/components/features/composite/composite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ export class Composite extends Component<CompositeProps & WithTranslation<'compo
state: Readonly<CompositeState> = {};
onChange = (endpoint: Endpoint, value: Record<string, unknown>): 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);
}
Expand All @@ -40,7 +39,13 @@ export class Composite extends Component<CompositeProps & WithTranslation<'compo

isCompositeRoot = (): boolean => {
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 => {
Expand Down
8 changes: 7 additions & 1 deletion src/components/features/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ class List extends Component<Props, State> {
};

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[] {
Expand Down

0 comments on commit 5803577

Please sign in to comment.