Skip to content

Commit

Permalink
Fixes React errors+crash when system theme changes on loaded dashboard (
Browse files Browse the repository at this point in the history
#1123)

* Fixes crash on theme change

* Changelog
  • Loading branch information
Vigasaurus authored Jun 14, 2021
1 parent 39287ab commit 6450692
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
- Fix weekly report time range plausible/analytics#951
- Make sure embedded dashboards can run when user has blocked third-party cookies plausible/analytics#971
- Sites listing page will paginate if the user has a lot of sites plausible/analytics#994
- Crash when changing theme on a loaded dashboard plausible/analytics#1123

### Removed
- Removes AppSignal monitoring package
Expand Down
4 changes: 2 additions & 2 deletions assets/js/dashboard/stats/countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class Countries extends React.Component {
componentDidUpdate(prevProps) {
if (this.props.query !== prevProps.query) {
this.setState({loading: true, countries: null})
this.fetchCountries().then(this.drawMap.bind(this))
this.fetchCountries().then(this.drawMap)
}

if (this.props.darkTheme !== prevProps.darkTheme) {
if (document.getElementById('map-container')) {
document.getElementById('map-container').removeChild(document.querySelector('.datamaps-hoverover'));
document.getElementById('map-container').removeChild(document.querySelector('.datamap'));
}
this.drawMap();
this.fetchCountries().then(this.drawMap)
}
}

Expand Down
1 change: 1 addition & 0 deletions assets/js/dashboard/stats/visitor-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class LineGraph extends React.Component {
}

if (prevProps.darkTheme !== this.props.darkTheme) {
this.chart.destroy();
this.chart = this.regenerateChart();
this.chart.update();
}
Expand Down

0 comments on commit 6450692

Please sign in to comment.