Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Restore map tab when removing region filter

Uku Taht383bba947ead
diff --git a/assets/js/dashboard/stats/locations/index.js b/assets/js/dashboard/stats/locations/index.js
index 4f9fc621c7..216cf37e49 100644
--- a/assets/js/dashboard/stats/locations/index.js
+++ b/assets/js/dashboard/stats/locations/index.js
@@ -106,7 +106,7 @@ export default class Locations extends React.Component {
}
if (this.state.mode === 'regions' && isRemovingFilter('country')) {
- this.setMode('countries')()
+ this.setMode(this.countriesRestoreMode || 'countries')()
}
}
@@ -117,8 +117,11 @@ export default class Locations extends React.Component {
}
}
- onCountryFilter() {
- this.setMode('regions')()
+ onCountryFilter(mode) {
+ return () => {
+ this.countriesRestoreMode = mode
+ this.setMode('regions')()
+ }
}
onRegionFilter() {
@@ -132,10 +135,10 @@ export default class Locations extends React.Component {
case "regions":
return <Regions onClick={this.onRegionFilter} site={this.props.site} query={this.props.query} timer={this.props.timer}/>
case "countries":
- return <Countries onClick={this.onCountryFilter} site={this.props.site} query={this.props.query} timer={this.props.timer}/>
+ return <Countries onClick={this.onCountryFilter('countries')} site={this.props.site} query={this.props.query} timer={this.props.timer}/>
case "map":
default:
- return <CountriesMap site={this.props.site} query={this.props.query} timer={this.props.timer}/>
+ return <CountriesMap onClick={this.onCountryFilter('map')} site={this.props.site} query={this.props.query} timer={this.props.timer}/>
}
}
diff --git a/assets/js/dashboard/stats/locations/map.js b/assets/js/dashboard/stats/locations/map.js
index 55c84dea46..c9de680b05 100644
--- a/assets/js/dashboard/stats/locations/map.js
+++ b/assets/js/dashboard/stats/locations/map.js
@@ -109,14 +109,19 @@ class Countries extends React.Component {
datamap.svg.selectAll('.datamaps-subunit').on('click', (geography) => {
const country = this.state.countries.find(c => c.alpha_3 === geography.id)
- navigateToQuery(
- this.props.history,
- this.props.query,
- {
- country: country.code,
- country_name: country.name
- }
- )
+ if (country) {
+ this.props.onClick()
+
+ navigateToQuery(
+ this.props.history,
+ this.props.query,
+ {
+ country: country.code,
+ country_name: country.name
+ }
+ )
+ }
+
})
}
});