Files
grafana/public/app/features/dashboard-scene/scene/hoverHeaderOffsetBehavior.ts
Sergej-Vlasov 79631bdd15 DashboardScene: prevent panel hovel header crop with scenes (#85869)
* 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

* bump scenes version

* Revert "Fix transformation tab tests"

This reverts commit 3ec9f5b226.

---------

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>
2024-04-10 20:39:43 +03:00

19 lines
587 B
TypeScript

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();
};
};