Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 50e1bc7

Browse files
authored
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.
1 parent 2dd7068 commit 50e1bc7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

assets/javascripts/discourse/components/admin-report-sentiment-analysis.gjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,15 @@ export default class AdminReportSentimentAnalysis extends Component {
216216
}
217217

218218
const currentQueryParams = this.router.currentRoute.queryParams;
219+
220+
const currentFilters = currentQueryParams?.filters
221+
? JSON.parse(currentQueryParams.filters)
222+
: {};
223+
219224
this.router.transitionTo(this.router.currentRoute.name, {
220225
queryParams: {
221226
...currentQueryParams,
222-
filters: JSON.parse(currentQueryParams.filters), // avoids a double escaping
227+
filters: currentFilters, // avoids a double escaping
223228
selectedChart: data.title,
224229
},
225230
});
@@ -265,10 +270,13 @@ export default class AdminReportSentimentAnalysis extends Component {
265270
this.posts = [];
266271

267272
const currentQueryParams = this.router.currentRoute.queryParams;
273+
const currentFilters = currentQueryParams?.filters
274+
? JSON.parse(currentQueryParams.filters)
275+
: {};
268276
this.router.transitionTo(this.router.currentRoute.name, {
269277
queryParams: {
270278
...currentQueryParams,
271-
filters: JSON.parse(currentQueryParams.filters), // avoids a double escaping
279+
filters: currentFilters, // avoids a double escaping
272280
selectedChart: null,
273281
},
274282
});

0 commit comments

Comments
 (0)