Dashboard: Fix lost selection state issue (#103611)

Dashboard: Fix lost selection state issue!
This commit is contained in:
Torkel Ödegaard
2025-04-09 06:42:23 +02:00
committed by GitHub
parent a9ddef1c3c
commit d74b75f744
2 changed files with 11 additions and 16 deletions
@@ -1,6 +1,5 @@
import { css, cx } from '@emotion/css';
import { Resizable } from 're-resizable';
import { useEffect } from 'react';
import { useLocalStorage } from 'react-use';
import { GrafanaTheme2 } from '@grafana/data';
@@ -191,21 +190,6 @@ export interface Props {
* Making the EditPane rendering completely standalone (not using editPane.Component) in order to pass custom react props
*/
export function DashboardEditPaneRenderer({ editPane, isCollapsed, onToggleCollapse, openOverlay }: Props) {
// Activate the edit pane
useEffect(() => {
editPane.enableSelection();
return () => {
editPane.disableSelection();
};
}, [editPane]);
useEffect(() => {
if (isCollapsed) {
editPane.clearSelection();
}
}, [editPane, isCollapsed]);
const { selection } = useSceneObjectState(editPane, { shouldActivateOrKeepAlive: true });
const styles = useStyles2(getStyles);
const editableElement = useEditableElement(selection, editPane);
@@ -57,6 +57,17 @@ export function DashboardEditPaneSplitter({ dashboard, isEditing, body, controls
setIsCollapsed(splitterState.collapsed);
}, [splitterState.collapsed, setIsCollapsed]);
/**
* Enable / disable selection based on dashboard isEditing state
*/
useEffect(() => {
if (isEditing) {
editPane.enableSelection();
} else {
editPane.clearSelection();
}
}, [isEditing, editPane]);
const { selectionContext } = useSceneObjectState(editPane, { shouldActivateOrKeepAlive: true });
const containerStyle: CSSProperties = {};