@@ -2,7 +2,7 @@ import React from 'react';
2
2
3
3
import { Xmark } from '@gravity-ui/icons' ;
4
4
import { DrawerItem , Drawer as GravityDrawer } from '@gravity-ui/navigation' ;
5
- import { ActionTooltip , Button , Flex , Icon , Text } from '@gravity-ui/uikit' ;
5
+ import { ActionTooltip , Button , Flex , Icon , Portal , Text } from '@gravity-ui/uikit' ;
6
6
7
7
import { cn } from '../../utils/cn' ;
8
8
import { isNumeric } from '../../utils/utils' ;
@@ -52,7 +52,7 @@ const DrawerPaneContentWrapper = ({
52
52
} ) ;
53
53
54
54
const drawerRef = React . useRef < HTMLDivElement > ( null ) ;
55
- const { containerWidth} = useDrawerContext ( ) ;
55
+ const { containerWidth, itemContainerRef } = useDrawerContext ( ) ;
56
56
// Calculate drawer width based on container width percentage if specified
57
57
const calculatedWidth = React . useMemo ( ( ) => {
58
58
if ( isPercentageWidth && containerWidth > 0 ) {
@@ -103,29 +103,36 @@ const DrawerPaneContentWrapper = ({
103
103
( event . nativeEvent as DrawerEvent ) . _capturedInsideDrawer = true ;
104
104
} ;
105
105
106
+ const itemContainer = itemContainerRef ?. current ;
107
+ if ( ! itemContainer ) {
108
+ return null ;
109
+ }
110
+
106
111
return (
107
- < GravityDrawer
108
- onEscape = { onClose }
109
- onVeilClick = { onClose }
110
- hideVeil
111
- className = { b ( 'container' , className ) }
112
- >
113
- < DrawerItem
114
- id = { drawerId }
115
- visible = { isVisible }
116
- resizable
117
- maxResizeWidth = { containerWidth }
118
- width = { isPercentageWidth ? calculatedWidth : drawerWidth }
119
- onResize = { handleResizeDrawer }
120
- direction = { direction }
121
- className = { b ( 'item' ) }
122
- ref = { detectClickOutside ? drawerRef : undefined }
112
+ < Portal container = { itemContainer } >
113
+ < GravityDrawer
114
+ onEscape = { onClose }
115
+ onVeilClick = { onClose }
116
+ hideVeil
117
+ className = { b ( 'container' , className ) }
123
118
>
124
- < div className = { b ( 'click-handler' ) } onClickCapture = { handleClickInsideDrawer } >
125
- { children }
126
- </ div >
127
- </ DrawerItem >
128
- </ GravityDrawer >
119
+ < DrawerItem
120
+ id = { drawerId }
121
+ visible = { isVisible }
122
+ resizable
123
+ maxResizeWidth = { containerWidth }
124
+ width = { isPercentageWidth ? calculatedWidth : drawerWidth }
125
+ onResize = { handleResizeDrawer }
126
+ direction = { direction }
127
+ className = { b ( 'item' ) }
128
+ ref = { detectClickOutside ? drawerRef : undefined }
129
+ >
130
+ < div className = { b ( 'click-handler' ) } onClickCapture = { handleClickInsideDrawer } >
131
+ { children }
132
+ </ div >
133
+ </ DrawerItem >
134
+ </ GravityDrawer >
135
+ </ Portal >
129
136
) ;
130
137
} ;
131
138
0 commit comments