If no children dont show chevron

Reviewed By: lawrencelomax

Differential Revision: D41809088

fbshipit-source-id: 7f4bef5390561671cc53a12be8aa99ea5efe228c
This commit is contained in:
Luke De Feo
2022-12-12 07:28:37 -08:00
committed by Facebook GitHub Bot
parent 0e51914e9e
commit 8784691e62

View File

@@ -133,8 +133,9 @@ function TreeItemContainer({
onSelectNode(treeNode.id);
}}
item={treeNode}>
<Arrow
<ExpandedIconOrSpace
expanded={treeNode.isExpanded}
children={treeNode.children}
onClick={() => {
instance.uiState.expandedNodes.update((draft) => {
if (draft.has(treeNode.id)) {
@@ -145,7 +146,6 @@ function TreeItemContainer({
});
}}
/>
{nodeIcon(treeNode)}
<HighlightedText text={treeNode.name} />
</TreeItem>
@@ -189,8 +189,12 @@ const TreeItem = styled.li<{
backgroundColor: isSelected ? theme.selectionBackgroundColor : theme.white,
}));
function Arrow(props: {onClick: () => void; expanded: boolean}) {
return (
function ExpandedIconOrSpace(props: {
onClick: () => void;
expanded: boolean;
children: Id[];
}) {
return props.children.length > 0 ? (
<div style={{display: 'flex'}} onClick={props.onClick}>
<Glyph
style={{
@@ -203,6 +207,8 @@ function Arrow(props: {onClick: () => void; expanded: boolean}) {
color="grey"
/>
</div>
) : (
<div style={{width: '12px'}}></div>
);
}