Commit 7eb2558f by Dominik Prokop

Fix issue with graph legend color picker disapearing on color selection

parent 6b1390b9
......@@ -21,8 +21,7 @@ export const ThemeProvider = ({ children }: { children: React.ReactNode }) => {
return (
<ConfigConsumer>
{config => {
const currentTheme = getCurrentThemeName();
return <ThemeContext.Provider value={getTheme(currentTheme)}>{children}</ThemeContext.Provider>;
return <ThemeContext.Provider value={getCurrentTheme()}>{children}</ThemeContext.Provider>;
}}
</ConfigConsumer>
);
......
......@@ -28,6 +28,8 @@ import { GraphCtrl } from './module';
import { GrafanaThemeType, getValueFormat } from '@grafana/ui';
import { provideTheme } from 'app/core/utils/ConfigProvider';
const LegendWithThemeProvider = provideTheme(Legend);
class GraphElement {
ctrl: GraphCtrl;
tooltip: any;
......@@ -44,6 +46,7 @@ class GraphElement {
legendElem: HTMLElement;
constructor(private scope, private elem, private timeSrv) {
this.ctrl = scope.ctrl;
this.dashboard = this.ctrl.dashboard;
this.panel = this.ctrl.panel;
......@@ -110,7 +113,7 @@ class GraphElement {
onToggleAxis: this.ctrl.onToggleAxis,
};
const legendReactElem = React.createElement(provideTheme(Legend), legendProps);
const legendReactElem = React.createElement(LegendWithThemeProvider, legendProps);
ReactDOM.render(legendReactElem, this.legendElem, () => this.renderPanel());
}
......
......@@ -29,7 +29,7 @@ function getThemeVariable(variablePath, themeName) {
const variable = get(theme, variablePath.getValue());
if (!variable) {
throw new Error(`${variablePath} is not defined fo ${themeName}`);
throw new Error(`${variablePath.getValue()} is not defined for ${themeName.getValue()} theme`);
}
if (isHex(variable)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment