Skip to content

Commit

Permalink
fix(composer): Fix for displaying children on search results (#365)
Browse files Browse the repository at this point in the history
Co-authored-by: Emily Dodds <dodemily@amazon.com>
  • Loading branch information
mumanity and mumanity committed Nov 15, 2022
1 parent 6dc40b9 commit 15f75cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
6 changes: 3 additions & 3 deletions packages/scene-composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@
"jest": {
"coverageThreshold": {
"global": {
"lines": 77.48,
"statements": 76.58,
"lines": 77.51,
"statements": 76.6,
"functions": 76.76,
"branches": 63.0,
"branches": 63.17,
"branchesTrue": 100
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,8 @@ const SceneHierarchyTreeItem: FC<SceneHierarchyTreeItemProps> = ({
}: SceneHierarchyTreeItemProps) => {
const [expanded, setExpanded] = useState(defaultExpanded);

const {
selected,
select,
unselect,
getChildNodes,
activate,
move,
selectionMode,
getObject3DBySceneNodeRef,
isViewing,
} = useSceneHierarchyData();
const { selected, select, unselect, activate, move, selectionMode, getObject3DBySceneNodeRef, isViewing } =
useSceneHierarchyData();

const model = getObject3DBySceneNodeRef(key) as Object3D | undefined;
const [childNodes] = useChildNodes(key);
Expand All @@ -55,6 +46,8 @@ const SceneHierarchyTreeItem: FC<SceneHierarchyTreeItemProps> = ({
const sceneComposerId = useContext(sceneComposerIdContext);
const { getSceneNodeByRef } = useSceneDocument(sceneComposerId);
const isSubModel = !!findComponentByType(getSceneNodeByRef(key), KnownComponentType.SubModelRef);
const { searchTerms } = useSceneHierarchyData();
const isSearching = searchTerms !== '';

const onExpandNode = useCallback((expanded) => {
setExpanded(expanded);
Expand Down Expand Up @@ -102,10 +95,14 @@ const SceneHierarchyTreeItem: FC<SceneHierarchyTreeItemProps> = ({
<EnhancedTree droppable={enableDragAndDrop} acceptDrop={AcceptableDropTypes} onDropped={dropHandler}>
{childNodes.map((node, index) => (
<React.Fragment key={index}>
<SceneHierarchyTreeItem key={node.objectRef} enableDragAndDrop={enableDragAndDrop} {...node} />
{!isSearching && (
<SceneHierarchyTreeItem key={node.objectRef} enableDragAndDrop={enableDragAndDrop} {...node} />
)}
</React.Fragment>
))}
{showSubModel && <SubModelTree parentRef={key} expanded={false} object3D={model!} selectable />}
{showSubModel && !isSearching && (
<SubModelTree parentRef={key} expanded={false} object3D={model!} selectable />
)}
</EnhancedTree>
)}
</EnhancedTreeItem>
Expand Down

0 comments on commit 15f75cb

Please sign in to comment.