@@ -27,11 +27,10 @@ export class Composite extends Component<CompositeProps & WithTranslation<'compo
27
27
state : Readonly < CompositeState > = { } ;
28
28
onChange = ( endpoint : Endpoint , value : Record < string , unknown > ) : void => {
29
29
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 ( ) ) {
33
32
if ( isCompositeFeature ( feature ) ) {
34
- onChange ( endpoint , feature . property ? { [ feature . property ] : value } : value ) ;
33
+ onChange ( endpoint , feature . property ? { [ feature . property ] : { ... this . state , ... value } } : value ) ;
35
34
} else {
36
35
onChange ( endpoint , value ) ;
37
36
}
@@ -40,7 +39,13 @@ export class Composite extends Component<CompositeProps & WithTranslation<'compo
40
39
41
40
isCompositeRoot = ( ) : boolean => {
42
41
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
+ ) ;
44
49
} ;
45
50
46
51
onCompositeFeatureApply = ( ) : void => {
0 commit comments