[v10.0.x] Graph: Fix bug with showing/hiding the legend (#68829)

Graph: Fix bug with showing/hiding the legend (#68774)

* don't unmount the root when hiding the legend

* update comment

(cherry picked from commit 0b6c5722a5)

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2023-05-22 16:05:41 +02:00
committed by GitHub
co-authored by Ashley Harrison
parent d62f2989a8
commit 4b66d1286e
+7 -2
View File
@@ -136,9 +136,14 @@ class GraphElement {
if (!this.panel.legend.show) {
if (this.legendElem.hasChildNodes()) {
this.legendElemRoot.unmount();
this.legendElemRoot.render(null);
}
this.renderPanel();
// we need to wait for react to finish rendering the legend before we can render the graph
// this is a slightly worse version of the `renderCallback` logic we use below
// the problem here is there's nothing to pass a `renderCallback` to since we don't want to render the legend at all.
setTimeout(() => {
this.renderPanel();
});
return;
}