Skip to content

Commit

Permalink
UX: remove the none options from the categories dropdown (#116)
Browse files Browse the repository at this point in the history
* UX: remove the none options from the categories dropdown
  • Loading branch information
jmperez127 committed Aug 18, 2023
1 parent 00efdea commit 0a7de65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
@@ -1,9 +1,6 @@
import { withPluginApi } from "discourse/lib/plugin-api";
import { ajax } from "discourse/lib/ajax";
import {
ALL_CATEGORIES_ID,
NO_CATEGORIES_ID,
} from "select-kit/components/category-drop";
import { ALL_CATEGORIES_ID } from "select-kit/components/category-drop";

const PLUGIN_ID = "discourse-global-filter-category-drop-options";

Expand Down Expand Up @@ -47,20 +44,6 @@ function setCategoryDropOptionsPerGlobalFilter(api) {
};

api.modifySelectKit("category-drop").replaceContent((categoryDrop) => {
if (
categoryDrop.selectKit.options.subCategory &&
(categoryDrop.value ||
!categoryDrop.selectKit.options.noSubcategories)
) {
categoriesAndSubcategories.subcategories = [
{
id: NO_CATEGORIES_ID,
name: categoryDrop.noCategoriesLabel,
},
...categoriesAndSubcategories.subcategories,
];
}

if (
(categoryDrop.value && !categoryDrop.editingCategory) ||
(categoryDrop.selectKit.options.noSubcategories &&
Expand Down
5 changes: 2 additions & 3 deletions test/javascripts/acceptance/set-category-drop-options-test.js
Expand Up @@ -101,9 +101,8 @@ acceptance(
await categories.expand();

// includes default values
assert.strictEqual(categories.rowByIndex(0).value(), "no-categories");
assert.strictEqual(categories.rowByIndex(1).value(), "102");
assert.strictEqual(categories.rows().length, 2);
assert.strictEqual(categories.rowByIndex(0).value(), "102");
assert.strictEqual(categories.rows().length, 1);
});

test("does not limit options to GFT categories when filtering", async function (assert) {
Expand Down

0 comments on commit 0a7de65

Please sign in to comment.