mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +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:
@ -79,6 +79,7 @@ export default Component.extend(FilterModeMixin, {
|
|||||||
return NavItem.buildList(category, {
|
return NavItem.buildList(category, {
|
||||||
filterType,
|
filterType,
|
||||||
noSubcategories,
|
noSubcategories,
|
||||||
|
currentRouteQueryParams,
|
||||||
persistedQueryParams: params,
|
persistedQueryParams: params,
|
||||||
siteSettings: this.siteSettings
|
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) {
|
if (queryParams.length) {
|
||||||
href += `?${queryParams.join("&")}`;
|
href += `?${queryParams.join("&")}`;
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,9 @@ NavItem.reopenClass({
|
|||||||
if (opts.tagId) {
|
if (opts.tagId) {
|
||||||
args.tagId = opts.tagId;
|
args.tagId = opts.tagId;
|
||||||
}
|
}
|
||||||
|
if (opts.currentRouteQueryParams) {
|
||||||
|
args.currentRouteQueryParams = opts.currentRouteQueryParams;
|
||||||
|
}
|
||||||
if (opts.persistedQueryParams) {
|
if (opts.persistedQueryParams) {
|
||||||
args.persistedQueryParams = opts.persistedQueryParams;
|
args.persistedQueryParams = opts.persistedQueryParams;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,10 @@ import { scrollTop } from "discourse/mixins/scroll-top";
|
|||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
|
|
||||||
export default DiscourseRoute.extend(OpenComposer, {
|
export default DiscourseRoute.extend(OpenComposer, {
|
||||||
|
queryParams: {
|
||||||
|
filter: { refreshModel: true }
|
||||||
|
},
|
||||||
|
|
||||||
redirect() {
|
redirect() {
|
||||||
return this.redirectIfLoginRequired();
|
return this.redirectIfLoginRequired();
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user