diff --git a/public/app/features/dashboard-scene/panel-edit/PanelEditorRenderer.tsx b/public/app/features/dashboard-scene/panel-edit/PanelEditorRenderer.tsx index 61b8b7cf138..13336861001 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelEditorRenderer.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelEditorRenderer.tsx @@ -25,6 +25,11 @@ export function PanelEditorRenderer({ model }: SceneComponentProps) const { optionsPane } = model.useState(); const styles = useStyles2(getWrapperStyles); const [isInitiallyCollapsed, setIsCollapsed] = useEditPaneCollapsed(); + const [containerRef, { height: containerHeight }] = useMeasure(); + + useEffect(() => { + console.log('PanelEditorRenderer containerHeight', containerHeight); + }, [containerHeight]); const isScrollingLayout = useScrollReflowLimit(); @@ -46,7 +51,7 @@ export function PanelEditorRenderer({ model }: SceneComponentProps) }, [splitterState.collapsed, setIsCollapsed]); return ( - <> +
) data-testid={selectors.components.PanelEditor.General.content} >
- +
@@ -77,18 +82,20 @@ export function PanelEditorRenderer({ model }: SceneComponentProps) {!splitterState.collapsed && !optionsPane && }
- +
); } -function VizAndDataPane({ model }: SceneComponentProps) { +function VizAndDataPane({ + model, + containerHeight = 800, +}: SceneComponentProps & { containerHeight?: number }) { const dashboard = getDashboardSceneFor(model); const { dataPane, showLibraryPanelSaveModal, showLibraryPanelUnlinkModal, tableView } = model.useState(); const panel = model.getPanel(); const libraryPanel = getLibraryPanelBehavior(panel); const { controls } = dashboard.useState(); const [sidebarState, setSidebarState] = useState({ size: SidebarSize.Mini, collapsed: false }); - const [containerRef, { height: containerHeight }] = useMeasure(); const [vizRef, { height: vizHeight }] = useMeasure(); const styles = useStyles2(getStyles, sidebarState); @@ -100,15 +107,14 @@ function VizAndDataPane({ model }: SceneComponentProps) { const grid = []; if (controls) { - rows.push('auto'); + rows.push('32px'); grid.push(['controls', 'controls']); } grid.push(['viz', 'viz']); - rows.push('1fr'); + rows.push(`${vizHeight}px`); if (dataPane) { - // rows.push(`${(containerHeight - vizHeight) + 40}px`); rows.push('auto'); grid.push(['sidebar', 'data-pane']); if (sidebarState.size === SidebarSize.Full) { @@ -119,20 +125,30 @@ function VizAndDataPane({ model }: SceneComponentProps) { } return { + height: containerHeight, + maxHeight: containerHeight, gridTemplateAreas: '\n' + grid.map((row) => `"${row.join(' ')}"`).join('\n'), - // gridTemplateRows: rows.map((r) => r).join(' '), + gridTemplateRows: rows.map((r) => r).join(' '), }; - }, [controls, dataPane, sidebarState.size]); + }, [controls, dataPane, sidebarState.size, vizHeight, containerHeight]); + + if (!containerHeight) { + return null; + } return ( -
+
{controls && (
)} -
+
{tableView ? : }
@@ -216,10 +232,6 @@ function getStyles(theme: GrafanaTheme2, sidebarState: SidebarState) { display: 'grid', gap: theme.spacing(2), gridTemplateColumns: `auto 1fr`, - gridTemplateRows: `auto 0.7fr 0.3fr`, - height: '100%', - minHeight: '100%', - maxHeight: '100%', overflow: 'hidden', [scrollReflowMediaQuery]: { gridTemplateColumns: `100%`, @@ -239,14 +251,15 @@ function getStyles(theme: GrafanaTheme2, sidebarState: SidebarState) { gridArea: 'viz', overflow: 'auto', resize: 'vertical', - minHeight: 200, - maxHeight: 700, // FIXME: needs a dynamic height + height: '100%', + minHeight: 100, ...(sidebarState.size === SidebarSize.Mini && { paddingLeft: theme.spacing(2), }), }), dataPane: css({ gridArea: 'data-pane', + overflow: 'hidden', }), controlsWrapper: css({ gridArea: 'controls',