diff --git a/public/app/features/dashboard-scene/scene/PanelLinks.tsx b/public/app/features/dashboard-scene/scene/PanelLinks.tsx index 3e46299dc83..df44a16f6a4 100644 --- a/public/app/features/dashboard-scene/scene/PanelLinks.tsx +++ b/public/app/features/dashboard-scene/scene/PanelLinks.tsx @@ -1,5 +1,12 @@ import { DataLink, LinkModel } from '@grafana/data'; -import { SceneComponentProps, SceneObjectBase, SceneObjectState, VizPanel } from '@grafana/scenes'; +import { + SceneComponentProps, + sceneGraph, + SceneObjectBase, + SceneObjectState, + VariableDependencyConfig, + VizPanel, +} from '@grafana/scenes'; import { Dropdown, Icon, Menu, PanelChrome, ToolbarButton } from '@grafana/ui'; import { getPanelLinks } from './PanelMenuBehavior'; @@ -11,11 +18,20 @@ interface VizPanelLinksState extends SceneObjectState { } export class VizPanelLinks extends SceneObjectBase { + protected _variableDependency = new VariableDependencyConfig(this, { + onAnyVariableChanged: () => { + if (this.state.rawLinks && this.state.rawLinks.length > 0) { + this.forceRender(); + } + }, + }); + static Component = VizPanelLinksRenderer; } function VizPanelLinksRenderer({ model }: SceneComponentProps) { const { menu, rawLinks } = model.useState(); + sceneGraph.getTimeRange(model).useState(); if (!(model.parent instanceof VizPanel)) { throw new Error('VizPanelLinks must be a child of VizPanel');