FIX: unable to click doughnut when no filters (#1213)

This PR fixes an issue where you are unable to click to see the sentiment drill-down when there are no current filters applied. This is due to trying to `JSON.parse()` the filters when there are no filters. This fix ensures there are filters first before trying to parse the JSON.
This commit is contained in:
Keegan George 2025-03-24 10:10:22 -07:00 committed by GitHub
parent 2dd7068b46
commit 50e1bc774a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -216,10 +216,15 @@ export default class AdminReportSentimentAnalysis extends Component {
}
const currentQueryParams = this.router.currentRoute.queryParams;
const currentFilters = currentQueryParams?.filters
? JSON.parse(currentQueryParams.filters)
: {};
this.router.transitionTo(this.router.currentRoute.name, {
queryParams: {
...currentQueryParams,
filters: JSON.parse(currentQueryParams.filters), // avoids a double escaping
filters: currentFilters, // avoids a double escaping
selectedChart: data.title,
},
});
@ -265,10 +270,13 @@ export default class AdminReportSentimentAnalysis extends Component {
this.posts = [];
const currentQueryParams = this.router.currentRoute.queryParams;
const currentFilters = currentQueryParams?.filters
? JSON.parse(currentQueryParams.filters)
: {};
this.router.transitionTo(this.router.currentRoute.name, {
queryParams: {
...currentQueryParams,
filters: JSON.parse(currentQueryParams.filters), // avoids a double escaping
filters: currentFilters, // avoids a double escaping
selectedChart: null,
},
});