Skip to content

Commit

Permalink
Fix all controls showing with nothing selected
Browse files Browse the repository at this point in the history
Fixes #11
  • Loading branch information
joelspadin committed Jun 20, 2024
1 parent 9debb6d commit 99ff217
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/panel/PropertiesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,25 @@ const ControlCondition: React.FC<ControlConditionProps> = ({ objects, test, cont
return isValid ? <Control objects={objects} /> : null;
};

const NoObjectsMessage: React.FC = () => {
return <p>No objects selected.</p>;
};

const Controls: React.FC = () => {
const classes = useControlStyles();
const [selection] = useSelection();
const step = useCurrentStep();

if (selection.size === 0) {
return <p>No objects selected.</p>;
return <NoObjectsMessage />;
}

const objects = getSelectedObjects(step, selection);

if (objects.length === 0) {
return <NoObjectsMessage />;
}

return (
<>
<ControlCondition objects={objects} test={isNamed} control={NameControl} />
Expand Down

0 comments on commit 99ff217

Please sign in to comment.