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

* don't unmount the root when hiding the legend

* update comment
This commit is contained in:
Ashley Harrison 2023-05-22 14:57:56 +01:00 committed by GitHub
parent d4df5e0519
commit 0b6c5722a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}