Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes React errors+crash when system theme changes on loaded dashboard #1123

Merged
merged 2 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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