If no children dont show chevron
Reviewed By: lawrencelomax Differential Revision: D41809088 fbshipit-source-id: 7f4bef5390561671cc53a12be8aa99ea5efe228c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0e51914e9e
commit
8784691e62
@@ -133,8 +133,9 @@ function TreeItemContainer({
|
|||||||
onSelectNode(treeNode.id);
|
onSelectNode(treeNode.id);
|
||||||
}}
|
}}
|
||||||
item={treeNode}>
|
item={treeNode}>
|
||||||
<Arrow
|
<ExpandedIconOrSpace
|
||||||
expanded={treeNode.isExpanded}
|
expanded={treeNode.isExpanded}
|
||||||
|
children={treeNode.children}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
instance.uiState.expandedNodes.update((draft) => {
|
instance.uiState.expandedNodes.update((draft) => {
|
||||||
if (draft.has(treeNode.id)) {
|
if (draft.has(treeNode.id)) {
|
||||||
@@ -145,7 +146,6 @@ function TreeItemContainer({
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{nodeIcon(treeNode)}
|
{nodeIcon(treeNode)}
|
||||||
<HighlightedText text={treeNode.name} />
|
<HighlightedText text={treeNode.name} />
|
||||||
</TreeItem>
|
</TreeItem>
|
||||||
@@ -189,8 +189,12 @@ const TreeItem = styled.li<{
|
|||||||
backgroundColor: isSelected ? theme.selectionBackgroundColor : theme.white,
|
backgroundColor: isSelected ? theme.selectionBackgroundColor : theme.white,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function Arrow(props: {onClick: () => void; expanded: boolean}) {
|
function ExpandedIconOrSpace(props: {
|
||||||
return (
|
onClick: () => void;
|
||||||
|
expanded: boolean;
|
||||||
|
children: Id[];
|
||||||
|
}) {
|
||||||
|
return props.children.length > 0 ? (
|
||||||
<div style={{display: 'flex'}} onClick={props.onClick}>
|
<div style={{display: 'flex'}} onClick={props.onClick}>
|
||||||
<Glyph
|
<Glyph
|
||||||
style={{
|
style={{
|
||||||
@@ -203,6 +207,8 @@ function Arrow(props: {onClick: () => void; expanded: boolean}) {
|
|||||||
color="grey"
|
color="grey"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<div style={{width: '12px'}}></div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user