fix(customHomePage): fix hierarchy with long entity name (#14323)

This commit is contained in:
v-tarasevich-blitz-brain 2025-08-06 20:58:14 +03:00 committed by GitHub
parent cd3269a3b1
commit 19e99c882c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 6 deletions

View File

@ -10,14 +10,22 @@ const Wrapper = styled.div`
width: 100%;
`;
const InlineBlockWrapper = styled.div<{ $hasExpanded: boolean }>`
display: inline-block;
min-width: calc(100% - 20px);
${(props) => !props.$hasExpanded && 'width: calc(100% - 20px);'}
`;
export default function TreeNodesRenderer() {
const { nodes } = useTreeViewContext();
const { nodes, hasAnyExpanded } = useTreeViewContext();
return (
<Wrapper>
{nodes.map((node) => (
<TreeNodeRenderer node={node} depth={0} key={node.value} />
))}
</Wrapper>
<InlineBlockWrapper $hasExpanded={hasAnyExpanded}>
<Wrapper>
{nodes.map((node) => (
<TreeNodeRenderer node={node} depth={0} key={node.value} />
))}
</Wrapper>
</InlineBlockWrapper>
);
}

View File

@ -11,6 +11,7 @@ const DEFAULT_TREE_VIEW_CONTEXT: TreeViewContextType = {
getIsExpandable: () => false,
getIsExpanded: () => false,
hasAnyExpanded: false,
expand: () => {},
collapse: () => {},
toggleExpanded: () => {},

View File

@ -89,6 +89,8 @@ export default function TreeViewContextProvider({
[internalExpandedValues],
);
const hasAnyExpanded = useMemo(() => internalExpandedValues.length > 0, [internalExpandedValues.length]);
const expand = useCallback(
(node: TreeNode) => {
initialChildrenLoad(node); // try to load initial children on expand
@ -247,6 +249,7 @@ export default function TreeViewContextProvider({
// Expanding
getIsExpandable,
getIsExpanded,
hasAnyExpanded,
expand,
collapse,
toggleExpanded,

View File

@ -33,6 +33,7 @@ export interface TreeViewContextType {
// Expand
getIsExpandable: (node: TreeNode) => boolean;
getIsExpanded: (node: TreeNode) => boolean;
hasAnyExpanded: boolean;
expand: (node: TreeNode) => void;
collapse: (node: TreeNode) => void;
toggleExpanded: (node: TreeNode) => void;