Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/components/features/FeatureSubFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ function isFeatureRoot(type: FeatureWithAnySubFeatures["type"], parentFeatures:
return true;
}

// Check if any parent is a composite - if so, this composite is nested and should not be a root
if (parentFeatures.some((parent) => parent.type === "composite")) {
return false;
}

if (parentFeatures.length === 1) {
// When parent is e.g. climate
const parentType = parentFeatures[0].type;
Expand Down Expand Up @@ -94,21 +99,21 @@ export default function FeatureSubFeatures({

return (
<>
{features.map((feature) => (
{features.map((subFeature) => (
<Feature
// @ts-expect-error typing failure
key={getFeatureKey(feature)}
key={getFeatureKey(subFeature)}
// @ts-expect-error typing failure
feature={feature}
parentFeatures={parentFeatures ?? []}
feature={subFeature}
parentFeatures={[...(parentFeatures ?? []), feature]}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the FeatureSubFeatures>Features to always have at least 1 parent.
I'm not sure of the impact.

I think we'll need to add a couple mock devices to get a better idea of before/after.

device={device}
deviceState={combinedState}
onChange={onFeatureChange}
onRead={onFeatureRead}
featureWrapperClass={featureWrapperClass}
minimal={minimal}
endpointSpecific={endpointSpecific}
steps={steps?.[feature.name]}
steps={steps?.[subFeature.name]}
/>
))}
{isRoot && (
Expand Down