Fix issue with graph legend color picker disapearing on color selection

This commit is contained in:
Dominik Prokop 2019-02-06 15:06:27 +01:00
parent 6b1390b972
commit 7eb2558fc5
3 changed files with 6 additions and 4 deletions

View File

@ -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>
);

View File

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

View File

@ -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)) {