@@ -2,7 +2,7 @@ import React from 'react';
22
33import { Xmark } from '@gravity-ui/icons' ;
44import { 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' ;
66
77import { cn } from '../../utils/cn' ;
88import { isNumeric } from '../../utils/utils' ;
@@ -52,7 +52,7 @@ const DrawerPaneContentWrapper = ({
5252 } ) ;
5353
5454 const drawerRef = React . useRef < HTMLDivElement > ( null ) ;
55- const { containerWidth} = useDrawerContext ( ) ;
55+ const { containerWidth, itemContainerRef } = useDrawerContext ( ) ;
5656 // Calculate drawer width based on container width percentage if specified
5757 const calculatedWidth = React . useMemo ( ( ) => {
5858 if ( isPercentageWidth && containerWidth > 0 ) {
@@ -103,29 +103,36 @@ const DrawerPaneContentWrapper = ({
103103 ( event . nativeEvent as DrawerEvent ) . _capturedInsideDrawer = true ;
104104 } ;
105105
106+ const itemContainer = itemContainerRef ?. current ;
107+ if ( ! itemContainer ) {
108+ return null ;
109+ }
110+
106111 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 ) }
123118 >
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 >
129136 ) ;
130137} ;
131138
0 commit comments