mirror of
https://github.com/discourse/discourse.git
synced 2025-02-01 11:27:14 +08:00
FIX: Reset 'filter' query parameter when clicking on a nav-item (#10299)
Usually, this would have been implemented using resetController, but because we do not use link-to component for linking, that method is not called.
This commit is contained in:
parent
fd02856f80
commit
27d853e2ea
|
@ -79,6 +79,7 @@ export default Component.extend(FilterModeMixin, {
|
|||
return NavItem.buildList(category, {
|
||||
filterType,
|
||||
noSubcategories,
|
||||
currentRouteQueryParams,
|
||||
persistedQueryParams: params,
|
||||
siteSettings: this.siteSettings
|
||||
});
|
||||
|
|
|
@ -59,6 +59,17 @@ export default Component.extend(FilterModeMixin, {
|
|||
});
|
||||
}
|
||||
|
||||
// To reset the "filter" sticky param, at least one query param is needed.
|
||||
// If no query param is present, add an empty one to ensure a ? is
|
||||
// appended to the URL.
|
||||
if (content.currentRouteQueryParams) {
|
||||
if (content.currentRouteQueryParams.filter) {
|
||||
if (queryParams.length === 0) {
|
||||
queryParams.push("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (queryParams.length) {
|
||||
href += `?${queryParams.join("&")}`;
|
||||
}
|
||||
|
|
|
@ -172,6 +172,9 @@ NavItem.reopenClass({
|
|||
if (opts.tagId) {
|
||||
args.tagId = opts.tagId;
|
||||
}
|
||||
if (opts.currentRouteQueryParams) {
|
||||
args.currentRouteQueryParams = opts.currentRouteQueryParams;
|
||||
}
|
||||
if (opts.persistedQueryParams) {
|
||||
args.persistedQueryParams = opts.persistedQueryParams;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,10 @@ import { scrollTop } from "discourse/mixins/scroll-top";
|
|||
import User from "discourse/models/user";
|
||||
|
||||
export default DiscourseRoute.extend(OpenComposer, {
|
||||
queryParams: {
|
||||
filter: { refreshModel: true }
|
||||
},
|
||||
|
||||
redirect() {
|
||||
return this.redirectIfLoginRequired();
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user