From 2d5bb516a6aa035dca11dd55dfbb5b796c54c166 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Fri, 30 Oct 2020 06:26:20 +0530 Subject: [PATCH] FIX: keep tag filter value when changing the category dropdown. (#11065) Previously, while filtering the topics by tag, selecting a category loses the selected tag value. --- .../discourse/app/templates/components/bread-crumbs.hbs | 1 + .../select-kit/addon/components/category-drop.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs b/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs index cac57057ffe..d8c1ab13633 100644 --- a/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/bread-crumbs.hbs @@ -3,6 +3,7 @@ {{category-drop category=breadcrumb.category categories=breadcrumb.options + tagId=tagId options=(hash parentCategory=breadcrumb.parentCategory subCategory=breadcrumb.isSubcategory diff --git a/app/assets/javascripts/select-kit/addon/components/category-drop.js b/app/assets/javascripts/select-kit/addon/components/category-drop.js index 762d06b2aeb..a7d6e82e060 100644 --- a/app/assets/javascripts/select-kit/addon/components/category-drop.js +++ b/app/assets/javascripts/select-kit/addon/components/category-drop.js @@ -161,7 +161,14 @@ export default ComboBoxComponent.extend({ onChange(categoryId) { let categoryURL; - if (categoryId === ALL_CATEGORIES_ID) { + if (this.tagId && !this.category) { + const category = Category.findById(parseInt(categoryId, 10)); + categoryURL = getURL( + `/tags/c/${Category.slugFor(category)}/${ + category.id + }/${this.tagId.toLowerCase()}` + ); + } else if (categoryId === ALL_CATEGORIES_ID) { categoryURL = this.allCategoriesUrl; } else if (categoryId === NO_CATEGORIES_ID) { categoryURL = this.noCategoriesUrl;