diff --git a/desktop/app/src/PluginContainer.tsx b/desktop/app/src/PluginContainer.tsx index a43efbb6b..ca7f7a6bc 100644 --- a/desktop/app/src/PluginContainer.tsx +++ b/desktop/app/src/PluginContainer.tsx @@ -49,6 +49,7 @@ import {ToggleButton, SmallText, Layout} from './ui'; import {SandyPluginRenderer} from 'flipper-plugin'; import {isDevicePluginDefinition} from './utils/pluginUtils'; import ArchivedDevice from './devices/ArchivedDevice'; +import {ContentContainer} from './sandy-chrome/ContentContainer'; const Container = styled(FlexColumn)({ width: 0, @@ -436,7 +437,7 @@ class PluginContainer extends PureComponent { heading={`Plugin "${ activePlugin.title || 'Unknown' }" encountered an error during render`}> - {pluginElement} + {pluginElement} diff --git a/desktop/app/src/chrome/DetailSidebar.tsx b/desktop/app/src/chrome/DetailSidebar.tsx index 83701c30e..9960db5f4 100644 --- a/desktop/app/src/chrome/DetailSidebar.tsx +++ b/desktop/app/src/chrome/DetailSidebar.tsx @@ -7,14 +7,14 @@ * @format */ -import React, {useEffect, useMemo, useContext} from 'react'; +import React, {useEffect, useState} from 'react'; import ReactDOM from 'react-dom'; -import {ReactReduxContext} from 'react-redux'; import Sidebar from '../ui/components/Sidebar'; import {toggleRightSidebarAvailable} from '../reducers/application'; import {useDispatch, useStore} from '../utils/useStore'; import {useIsSandy} from '../sandy-chrome/SandyContext'; import {ContentContainer} from '../sandy-chrome/ContentContainer'; +import {Layout} from '../ui'; type OwnProps = { children: any; @@ -24,12 +24,13 @@ type OwnProps = { /* eslint-disable react-hooks/rules-of-hooks */ export default function DetailSidebar({children, width, minWidth}: OwnProps) { - const reduxContext = useContext(ReactReduxContext); - const domNode = useMemo(() => document.getElementById('detailsSidebar'), []); + const [domNode, setDomNode] = useState( + document.getElementById('detailsSidebar'), + ); - if (!reduxContext || !domNode) { + if (typeof jest !== 'undefined') { // For unit tests, make sure to render elements inline - return
{children}
; + return
{children}
; } const isSandy = useIsSandy(); @@ -49,6 +50,19 @@ export default function DetailSidebar({children, width, minWidth}: OwnProps) { [children, rightSidebarAvailable, dispatch], ); + // If the plugin container is mounting and rendering a sidbar immediately, the domNode might not yet be available + useEffect(() => { + if (!domNode) { + const newDomNode = document.getElementById('detailsSidebar'); + if (!newDomNode) { + // if after layouting domNode is still not available, something is wrong... + console.error('Failed to obtain detailsSidebar node'); + } else { + setDomNode(newDomNode); + } + } + }, [domNode]); + return ( (children && rightSidebarVisible && @@ -59,7 +73,15 @@ export default function DetailSidebar({children, width, minWidth}: OwnProps) { width={width || 300} position="right" gutter={isSandy}> - {isSandy ? {children} : children} + {isSandy ? ( + + + {children} + + + ) : ( + children + )} , domNode, )) || diff --git a/desktop/app/src/chrome/plugin-manager/__tests__/__snapshots__/PluginInstaller.node.tsx.snap b/desktop/app/src/chrome/plugin-manager/__tests__/__snapshots__/PluginInstaller.node.tsx.snap index 8886f7cb4..36cefb7c8 100644 --- a/desktop/app/src/chrome/plugin-manager/__tests__/__snapshots__/PluginInstaller.node.tsx.snap +++ b/desktop/app/src/chrome/plugin-manager/__tests__/__snapshots__/PluginInstaller.node.tsx.snap @@ -9,10 +9,10 @@ exports[`load PluginInstaller list 1`] = ` class="css-1qqef1i-View-FlexBox-FlexRow-ToolbarContainer e13mj6h80" >