A platform for community discussion. Free, open, simple.
FIX: Simplify navigation to subcategories page (#27053)
Bianca Nenciuf5a0da6eba8f
diff --git a/app/assets/javascripts/discourse/app/components/bread-crumbs.hbs b/app/assets/javascripts/discourse/app/components/bread-crumbs.hbsindex 93e1980f5b0..0562ed9eb97 100644--- a/app/assets/javascripts/discourse/app/components/bread-crumbs.hbs+++ b/app/assets/javascripts/discourse/app/components/bread-crumbs.hbs@@ -24,13 +24,11 @@@tagId={{this.tag.id}}@editingCategory={{this.editingCategory}}@editingCategoryTab={{this.editingCategoryTab}}- @filterType={{this.filterType}}@options={{hashparentCategory=breadcrumb.parentCategorysubCategory=breadcrumb.isSubcategorynoSubcategories=breadcrumb.noSubcategoriesautoFilterable=true- disableIfHasNoChildren=(eq this.filterType "categories")}}/></li>diff --git a/app/assets/javascripts/discourse/app/components/d-navigation.hbs b/app/assets/javascripts/discourse/app/components/d-navigation.hbsindex b666d512fe9..50d1f7afe93 100644--- a/app/assets/javascripts/discourse/app/components/d-navigation.hbs+++ b/app/assets/javascripts/discourse/app/components/d-navigation.hbs@@ -4,7 +4,6 @@@noSubcategories={{this.noSubcategories}}@tag={{this.tag}}@additionalTags={{this.additionalTags}}- @filterType={{this.filterType}}/>{{#unless this.additionalTags}}diff --git a/app/assets/javascripts/discourse/tests/acceptance/subcategories-test.js b/app/assets/javascripts/discourse/tests/acceptance/subcategories-test.jsdeleted file mode 100644index 2afc1b28b2b..00000000000--- a/app/assets/javascripts/discourse/tests/acceptance/subcategories-test.js+++ /dev/null@@ -1,32 +0,0 @@-import { currentRouteName, currentURL, visit } from "@ember/test-helpers";-import { test } from "qunit";-import { acceptance } from "discourse/tests/helpers/qunit-helpers";-import selectKit from "discourse/tests/helpers/select-kit-helper";--acceptance("Subcategories", function (needs) {- needs.site({- lazy_load_categories: true,- });-- test("navigation can be used to navigate subcategories pages", async function (assert) {- await visit("/categories");-- let categoryDrop = selectKit(- ".category-breadcrumb li:nth-of-type(1) .category-drop"- );- await categoryDrop.expand();- await categoryDrop.selectRowByValue("2"); // "feature" category-- assert.strictEqual(currentRouteName(), "discovery.subcategories");- assert.strictEqual(currentURL(), "/c/feature/2/subcategories");-- categoryDrop = selectKit(- ".category-breadcrumb li:nth-of-type(2) .category-drop"- );- await categoryDrop.expand();- await categoryDrop.selectRowByValue("26"); // "spec" category-- assert.strictEqual(currentRouteName(), "discovery.subcategories");- assert.strictEqual(currentURL(), "/c/feature/spec/26/subcategories");- });-});diff --git a/app/assets/javascripts/select-kit/addon/components/category-drop-more-collection.gjs b/app/assets/javascripts/select-kit/addon/components/category-drop-more-collection.gjsindex 8783e28385b..42b6e4bb316 100644--- a/app/assets/javascripts/select-kit/addon/components/category-drop-more-collection.gjs+++ b/app/assets/javascripts/select-kit/addon/components/category-drop-more-collection.gjs@@ -27,6 +27,12 @@ export default class CategoryDropMoreCollection extends Component {return this.args.selectKit.totalCount - currentCount;}+ get slugPath() {+ return this.args.selectKit.options.parentCategory.path.substring(+ "/c/".length+ );+ }+<template>{{#if this.moreCount}}<div class="category-drop-footer">@@ -35,10 +41,7 @@ export default class CategoryDropMoreCollection extends Component {</span>{{#if @selectKit.options.parentCategory}}- <LinkTo- @route="discovery.subcategories"- @model={{@selectKit.options.parentCategory.id}}- >+ <LinkTo @route="discovery.subcategories" @model={{this.slugPath}}>{{i18n "categories.view_all"}}{{icon "external-link-alt"}}</LinkTo>diff --git a/app/assets/javascripts/select-kit/addon/components/category-drop.js b/app/assets/javascripts/select-kit/addon/components/category-drop.jsindex 88fb3e13888..c218b924d0c 100644--- a/app/assets/javascripts/select-kit/addon/components/category-drop.js+++ b/app/assets/javascripts/select-kit/addon/components/category-drop.js@@ -46,7 +46,6 @@ export default ComboBoxComponent.extend({headerComponent: "category-drop/category-drop-header",parentCategory: false,allowUncategorized: "allowUncategorized",- disableIfHasNoChildren: false,},init() {@@ -94,7 +93,6 @@ export default ComboBoxComponent.extend({if (this.selectKit.options.subCategory &&- this.filterType !== "categories" &&(this.value || !this.selectKit.options.noSubcategories)) {shortcuts.push({@@ -236,20 +234,6 @@ export default ComboBoxComponent.extend({categoryId !== NO_CATEGORIES_ID,this.editingCategoryTab);- } else if (- this.site.lazy_load_categories &&- this.filterType === "categories"- ) {- // rendered on categories page- if (categoryId === "all-categories" || categoryId === "no-categories") {- route = this.selectKit.options.parentCategory- ? `${this.selectKit.options.parentCategory.url}/subcategories`- : "/categories";- } else if (categoryId) {- route = `${Category.findById(categoryId).url}/subcategories`;- } else {- route = "/categories";- }} else {route = getCategoryAndTagUrl(category,diff --git a/app/assets/javascripts/select-kit/addon/components/category-row.gjs b/app/assets/javascripts/select-kit/addon/components/category-row.gjsindex 73d749e2caf..aa2a44c017f 100644--- a/app/assets/javascripts/select-kit/addon/components/category-row.gjs+++ b/app/assets/javascripts/select-kit/addon/components/category-row.gjs@@ -90,13 +90,6 @@ export default class CategoryRow extends Component {return this.category.description_text;}- get isDisabled() {- return (- this.args.selectKit.options.disableIfHasNoChildren &&- this.args.item.has_children === false- );- }-@cachedget category() {if (isEmpty(this.rowValue)) {@@ -194,9 +187,7 @@ export default class CategoryRow extends Component {handleClick(event) {event.preventDefault();event.stopPropagation();- if (!this.isDisabled) {- this.args.selectKit.select(this.rowValue, this.args.item);- }+ this.args.selectKit.select(this.rowValue, this.args.item);return false;}@@ -234,13 +225,10 @@ export default class CategoryRow extends Component {event.preventDefault();} else if (event.key === "Enter") {event.stopImmediatePropagation();-- if (!this.isDisabled) {- this.args.selectKit.select(- this.args.selectKit.highlighted.id,- this.args.selectKit.highlighted- );- }+ this.args.selectKit.select(+ this.args.selectKit.highlighted.id,+ this.args.selectKit.highlighted+ );event.preventDefault();} else if (event.key === "Escape") {this.args.selectKit.close(event);@@ -283,7 +271,6 @@ export default class CategoryRow extends Component {(if this.isSelected "is-selected")(if this.isHighlighted "is-highlighted")(if this.isNone "is-none")- (if this.isDisabled "is-disabled")}}role="menuitemradio"data-index={{@index}}diff --git a/app/assets/stylesheets/common/select-kit/category-drop.scss b/app/assets/stylesheets/common/select-kit/category-drop.scssindex ce002cc8817..cfdae176144 100644--- a/app/assets/stylesheets/common/select-kit/category-drop.scss+++ b/app/assets/stylesheets/common/select-kit/category-drop.scss@@ -29,14 +29,6 @@font-weight: 700;}- &.is-disabled {- cursor: not-allowed;-- .badge-category__name {- color: var(--primary-low-mid);- }- }-.category-desc {font-weight: normal;color: var(--primary-medium);