Skip to content

Commit

Permalink
fix: unmount map when switching dashboard mode or changing active typ…
Browse files Browse the repository at this point in the history
…e [DHIS2-9558] (#1083)

* fix: call unmount when Plugin unmounts

* fix: unmount already called when switching vis
  • Loading branch information
jenniferarnesen authored Sep 21, 2020
1 parent f573db0 commit 147000e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
13 changes: 12 additions & 1 deletion src/components/Item/VisualizationItem/DefaultPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
}

Expand Down
9 changes: 2 additions & 7 deletions src/components/Item/VisualizationItem/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () =>
Expand Down

0 comments on commit 147000e

Please sign in to comment.