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%; 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() { export default function TreeNodesRenderer() {
const { nodes } = useTreeViewContext(); const { nodes, hasAnyExpanded } = useTreeViewContext();
return ( return (
<Wrapper> <InlineBlockWrapper $hasExpanded={hasAnyExpanded}>
{nodes.map((node) => ( <Wrapper>
<TreeNodeRenderer node={node} depth={0} key={node.value} /> {nodes.map((node) => (
))} <TreeNodeRenderer node={node} depth={0} key={node.value} />
</Wrapper> ))}
</Wrapper>
</InlineBlockWrapper>
); );
} }

View File

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

View File

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

View File

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