33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6- import React , { useRef , useCallback , useState , useEffect } from 'react' ;
6+ import React , { useRef , useCallback , useState , useEffect , useMemo } from 'react' ;
77import {
88 EuiButtonIcon ,
99 EuiFlexGroup ,
@@ -37,6 +37,14 @@ export function DevToolsIcon({
3737} ) {
3838 const [ modalVisible , setModalVisible ] = useState ( false ) ;
3939 const [ devToolTab , setDevToolTab ] = useState ( '' ) ;
40+ const [ sidecarPaddingRight , setSidecarPaddingRight ] = useState ( '0px' ) ;
41+
42+ useEffect ( ( ) => {
43+ const subscription = core . overlays . sidecar . getSidecarConfig$ ( ) . subscribe ( ( config ) => {
44+ setSidecarPaddingRight ( config ?. dockedMode === 'right' ? `${ config . paddingSize } px` : '0px' ) ;
45+ } ) ;
46+ return ( ) => subscription . unsubscribe ( ) ;
47+ } , [ core . overlays . sidecar ] ) ;
4048
4149 // Use refs to avoid closure issues
4250 const modalVisibleRef = useRef ( modalVisible ) ;
@@ -103,9 +111,36 @@ export function DevToolsIcon({
103111 } ;
104112 } , [ modalVisible , core . keyboardShortcut , closeModal ] ) ;
105113
106- const closeModalVisible = ( ) => {
114+ const closeModalVisible = useCallback ( ( ) => {
107115 setModalVisible ( false ) ;
108- } ;
116+ } , [ ] ) ;
117+
118+ const memoizedMainApp = useMemo (
119+ ( ) => (
120+ < MainApp
121+ devTools = { devTools }
122+ savedObjects = { core . savedObjects }
123+ notifications = { core . notifications }
124+ dataSourceEnabled = { ! ! deps . dataSource }
125+ dataSourceManagement = { deps . dataSourceManagement }
126+ useUpdatedUX
127+ setMenuMountPoint = { setMountPoint }
128+ RouterComponent = { MemoryRouter }
129+ defaultRoute = { devToolTab }
130+ onManageDataSource = { closeModalVisible }
131+ />
132+ ) ,
133+ [
134+ devTools ,
135+ core . savedObjects ,
136+ core . notifications ,
137+ deps . dataSource ,
138+ deps . dataSourceManagement ,
139+ setMountPoint ,
140+ devToolTab ,
141+ closeModalVisible ,
142+ ]
143+ ) ;
109144
110145 return (
111146 < >
@@ -130,7 +165,15 @@ export function DevToolsIcon({
130165 * but overlay mask has a default padding bottom that prevent the modal from covering the whole page.
131166 */
132167 < EuiOverlayMask className = "devToolsOverlayMask" headerZindexLocation = "below" >
133- < div style = { { width : '100vw' , height : '100vh' , maxWidth : '100vw' } } >
168+ < div
169+ style = { {
170+ width : '100vw' ,
171+ height : '100vh' ,
172+ maxWidth : '100vw' ,
173+ marginRight : sidecarPaddingRight ,
174+ position : 'relative' ,
175+ } }
176+ >
134177 < EuiButtonIcon
135178 iconType = "cross"
136179 onClick = { ( ) => setModalVisible ( false ) }
@@ -159,18 +202,7 @@ export function DevToolsIcon({
159202 </ EuiFlexGroup >
160203 </ EuiFlexItem >
161204 < EuiFlexItem className = "devAppWrapper" >
162- < MainApp
163- devTools = { devTools }
164- savedObjects = { core . savedObjects }
165- notifications = { core . notifications }
166- dataSourceEnabled = { ! ! deps . dataSource }
167- dataSourceManagement = { deps . dataSourceManagement }
168- useUpdatedUX
169- setMenuMountPoint = { setMountPoint }
170- RouterComponent = { MemoryRouter }
171- defaultRoute = { devToolTab }
172- onManageDataSource = { closeModalVisible }
173- />
205+ { memoizedMainApp }
174206 < EuiSpacer size = "s" />
175207 < EuiSmallButton
176208 iconType = "cross"
0 commit comments