DashboardScene: prevent panel hovel header crop with scenes (#85780)

* add behaviour that adjusts hoverHeaderOffset

* clean up behaviour logic

* optimise and extract behaviour to separate file

* fix hoverHeaderOffsetBehavior unsubscribe

* update to latest scenes version

* Fix PanelOptionsTest

* fix: test value for adhoc filter url param

* Fix transformation tab tests

---------

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
Co-authored-by: Darren Janeczek <darren.janeczek@grafana.com>
Co-authored-by: oscarkilhed <oscar.kilhed@grafana.com>
This commit is contained in:
Sergej-Vlasov
2024-04-10 15:39:51 +03:00
committed by GitHub
parent c602d9d6ad
commit 23f1732855
7 changed files with 59 additions and 17 deletions

View File

@@ -0,0 +1,18 @@
import { VizPanel } from '@grafana/scenes';
import { DashboardGridItem } from './DashboardGridItem';
export const hoverHeaderOffsetBehavior = (grid: DashboardGridItem) => {
const sub = grid.subscribeToState((newState, prevState) => {
if ([newState.y, prevState.y].includes(0) && newState.y !== prevState.y) {
grid.forEachChild((child) => {
if (child instanceof VizPanel && child.state.hoverHeader) {
child.setState({ hoverHeaderOffset: grid.state.y === 0 ? 0 : undefined });
}
});
}
});
return () => {
sub.unsubscribe();
};
};