File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
pages/DashBoardPage/pages/BoardEditor/components/LayerPanel Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { LoadingOutlined } from '@ant-design/icons' ;
2
2
import { Empty , Tree as AntTree , TreeProps as AntTreeProps } from 'antd' ;
3
3
import classnames from 'classnames' ;
4
+ import { MutableRefObject } from 'react' ;
4
5
import styled from 'styled-components/macro' ;
5
6
import {
6
7
FONT_SIZE_BODY ,
@@ -14,12 +15,19 @@ import {
14
15
15
16
interface TreeProps extends AntTreeProps {
16
17
loading : boolean ;
18
+ wrapperRef ?: MutableRefObject < HTMLDivElement > | null ;
17
19
}
18
20
19
- export function Tree ( { loading, treeData, ...treeProps } : TreeProps ) {
21
+ export function Tree ( {
22
+ loading,
23
+ wrapperRef,
24
+ treeData,
25
+ ...treeProps
26
+ } : TreeProps ) {
20
27
return (
21
28
< Wrapper
22
29
className = { classnames ( { container : loading || ! treeData ?. length } ) }
30
+ { ...( wrapperRef && { ref : wrapperRef } ) }
23
31
>
24
32
{ loading ? (
25
33
< LoadingOutlined />
Original file line number Diff line number Diff line change 18
18
19
19
import { Tree } from 'app/components' ;
20
20
import { renderIcon } from 'app/hooks/useGetVizIcon' ;
21
+ import useResizeObserver from 'app/hooks/useResizeObserver' ;
21
22
import { WidgetActionContext } from 'app/pages/DashBoardPage/components/ActionProvider/WidgetActionProvider' ;
22
23
import widgetManager from 'app/pages/DashBoardPage/components/WidgetManager' ;
23
24
import { FC , memo , useCallback , useContext } from 'react' ;
@@ -39,6 +40,11 @@ export const LayerTree: FC<{}> = memo(() => {
39
40
const editingWidgetIds = useSelector ( selectEditingWidgetIds ) ;
40
41
const selectedIds = useSelector ( selectSelectedIds ) ;
41
42
43
+ const { height, ref } = useResizeObserver ( {
44
+ refreshMode : 'debounce' ,
45
+ refreshRate : 200 ,
46
+ } ) ;
47
+
42
48
const treeSelect = useCallback (
43
49
( _ , { node, nativeEvent } ) => {
44
50
onEditSelectWidget ( {
@@ -86,6 +92,8 @@ export const LayerTree: FC<{}> = memo(() => {
86
92
onDrop = { onDrop }
87
93
treeData = { treeData }
88
94
selectedKeys = { selectedIds ? selectedIds . split ( ',' ) : [ ] }
95
+ height = { height }
96
+ wrapperRef = { ref }
89
97
defaultExpandAll
90
98
/>
91
99
) ;
You can’t perform that action at this time.
0 commit comments