SoloPanel: Fixes issue with solo route and scopes variable (#112769)

* SoloPanel: Fixes issue with solo route and scopes variable

* fix lint
This commit is contained in:
Torkel Ödegaard
2025-10-22 10:40:06 +02:00
committed by GitHub
parent 3391163f9c
commit df9b36292d
@@ -77,6 +77,7 @@ export function SoloPanelRenderer({ dashboard, panelId }: { dashboard: Dashboard
return (
<div className={styles.container}>
{renderHiddenVariables(dashboard)}
<SoloPanelContextProvider value={soloPanelContext} dashboard={dashboard} singleMatch={true}>
<body.Component model={body} />
</SoloPanelContextProvider>
@@ -84,6 +85,28 @@ export function SoloPanelRenderer({ dashboard, panelId }: { dashboard: Dashboard
);
}
// Some variables like ScopesVariable needs
// to be rendered for their logic to work even if hidden
function renderHiddenVariables(dashboard: DashboardScene) {
if (!dashboard.state.$variables) {
return null;
}
const variables = dashboard.state.$variables.state.variables;
return (
<>
{variables.map((variable) => {
if (variable.UNSAFE_renderAsHidden) {
return <variable.Component model={variable} key={variable.state.key} />;
}
return null;
})}
</>
);
}
const getStyles = (theme: GrafanaTheme2) => ({
container: css({
position: 'fixed',