Browse Source

Fix issue with graph legend color picker disapearing on color selection

Dominik Prokop 7 years ago
parent
commit
7eb2558fc5

+ 1 - 2
public/app/core/utils/ConfigProvider.tsx

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

+ 4 - 1
public/app/plugins/panel/graph/graph.ts

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

+ 1 - 1
scripts/webpack/getThemeVariable.js

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