From 4777c17e1d7cb624e829d13bde080cc215bac494 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Mon, 21 Sep 2020 14:11:52 +0200 Subject: [PATCH 1/2] fix: call unmount when Plugin unmounts --- .../Item/VisualizationItem/DefaultPlugin.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/Item/VisualizationItem/DefaultPlugin.js b/src/components/Item/VisualizationItem/DefaultPlugin.js index 8415526e8..eb28df41c 100644 --- a/src/components/Item/VisualizationItem/DefaultPlugin.js +++ b/src/components/Item/VisualizationItem/DefaultPlugin.js @@ -95,6 +95,17 @@ class DefaultPlugin extends Component { this.reloadPlugin(prevProps) } + componentWillUnmount() { + if ( + pluginManager.pluginIsAvailable( + this.props.item, + this.props.visualization + ) + ) { + pluginManager.unmount(this.props.item, this.getActiveType()) + } + } + getActiveType = () => this.props.visualization.activeType || this.props.item.type @@ -121,11 +132,11 @@ DefaultPlugin.contextTypes = { DefaultPlugin.propTypes = { classes: PropTypes.object, - useActiveType: PropTypes.bool, item: PropTypes.object, itemFilters: PropTypes.object, options: PropTypes.object, style: PropTypes.object, + useActiveType: PropTypes.bool, visualization: PropTypes.object, } From 4c7ee50c21eb2cf26fe4b20f2a6a500221381e94 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Mon, 21 Sep 2020 14:30:57 +0200 Subject: [PATCH 2/2] fix: unmount already called when switching vis --- src/components/Item/VisualizationItem/Item.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/Item/VisualizationItem/Item.js b/src/components/Item/VisualizationItem/Item.js index 0a09f0c73..c0e374b0b 100644 --- a/src/components/Item/VisualizationItem/Item.js +++ b/src/components/Item/VisualizationItem/Item.js @@ -254,13 +254,8 @@ export class Item extends Component { } onSelectActiveType = type => { - if (type === this.getActiveType()) { - return - } - - pluginManager.unmount(this.props.item, this.getActiveType()) - - this.props.onSelectActiveType(this.props.visualization.id, type) + type !== this.getActiveType() && + this.props.onSelectActiveType(this.props.visualization.id, type) } getActiveType = () =>