diff --git a/client/src/components/TagsMultiselect/HeadlessMultiselect.test.ts b/client/src/components/TagsMultiselect/HeadlessMultiselect.test.ts index ca97b4615bae..4ef562b2efdf 100644 --- a/client/src/components/TagsMultiselect/HeadlessMultiselect.test.ts +++ b/client/src/components/TagsMultiselect/HeadlessMultiselect.test.ts @@ -20,7 +20,7 @@ describe("HeadlessMultiselect", () => { }); }; - const sampleOptions = ["#named", "#named_2", "#named_3", "abc", "def", "ghi"]; + const sampleOptions = ["name:named", "name:named_2", "name:named_3", "abc", "def", "ghi"]; const selectors = { openButton: ".toggle-button", @@ -197,27 +197,27 @@ describe("HeadlessMultiselect", () => { const input = await open(wrapper); await keyPress(input, "Enter"); - expect(wrapper.emitted()["input"]?.[0]?.[0]).toEqual(["#named"]); + expect(wrapper.emitted()["input"]?.[0]?.[0]).toEqual(["name:named"]); await keyPress(input, "ArrowDown"); await keyPress(input, "Enter"); - expect(wrapper.emitted()["input"]?.[1]?.[0]).toEqual(["#named_2"]); + expect(wrapper.emitted()["input"]?.[1]?.[0]).toEqual(["name:named_2"]); }); it("deselects options via keyboard", async () => { const wrapper = mountWithProps({ options: sampleOptions, - selected: ["#named", "#named_2", "#named_3"], + selected: ["name:named", "name:named_2", "name:named_3"], }); const input = await open(wrapper); await keyPress(input, "Enter"); - expect(wrapper.emitted()["input"]?.[0]?.[0]).toEqual(["#named_2", "#named_3"]); + expect(wrapper.emitted()["input"]?.[0]?.[0]).toEqual(["name:named_2", "name:named_3"]); await keyPress(input, "ArrowDown"); await keyPress(input, "Enter"); - expect(wrapper.emitted()["input"]?.[1]?.[0]).toEqual(["#named", "#named_3"]); + expect(wrapper.emitted()["input"]?.[1]?.[0]).toEqual(["name:named", "name:named_3"]); }); it("allows for adding new options", async () => { @@ -243,26 +243,26 @@ describe("HeadlessMultiselect", () => { const options = wrapper.findAll(selectors.option); await options.at(0).trigger("click"); - expect(wrapper.emitted()["input"]?.[0]?.[0]).toEqual(["#named"]); + expect(wrapper.emitted()["input"]?.[0]?.[0]).toEqual(["name:named"]); await options.at(1).trigger("click"); - expect(wrapper.emitted()["input"]?.[1]?.[0]).toEqual(["#named_2"]); + expect(wrapper.emitted()["input"]?.[1]?.[0]).toEqual(["name:named_2"]); }); it("deselects options with mouse", async () => { const wrapper = mountWithProps({ options: sampleOptions, - selected: ["#named", "#named_2", "#named_3"], + selected: ["name:named", "name:named_2", "name:named_3"], }); await open(wrapper); const options = wrapper.findAll(selectors.option); await options.at(0).trigger("click"); - expect(wrapper.emitted()["input"]?.[0]?.[0]).toEqual(["#named_2", "#named_3"]); + expect(wrapper.emitted()["input"]?.[0]?.[0]).toEqual(["name:named_2", "name:named_3"]); await options.at(1).trigger("click"); - expect(wrapper.emitted()["input"]?.[1]?.[0]).toEqual(["#named", "#named_3"]); + expect(wrapper.emitted()["input"]?.[1]?.[0]).toEqual(["name:named", "name:named_3"]); }); }); }); diff --git a/client/src/components/TagsMultiselect/HeadlessMultiselect.vue b/client/src/components/TagsMultiselect/HeadlessMultiselect.vue index 3a07de33a790..95660d1ced83 100644 --- a/client/src/components/TagsMultiselect/HeadlessMultiselect.vue +++ b/client/src/components/TagsMultiselect/HeadlessMultiselect.vue @@ -15,6 +15,7 @@ import { computed, nextTick, ref, watch } from "vue"; import Vue2Teleport from "vue2-teleport"; import { useUid } from "@/composables/utils/uid"; +import { normalizeTag } from "@/stores/userTagsStore"; library.add(faCheck, faChevronUp, faPlus, faTags, faTimes); @@ -147,6 +148,8 @@ function getOptionWithId(id: number) { * was not part of the provided options */ function onOptionSelected(option: string) { + option = normalizeTag(option); + if (!optionsAsSet.value.has(option)) { emit("addOption", option); return; @@ -318,7 +321,7 @@ whenever(isOpen, async () => { :data-parent-id="props.id" class="headless-multiselect__option" role="option" - :aria-selected="props.selected.includes(option)" + :aria-selected="props.selected.includes(normalizeTag(option))" :class="{ invalid: i === 0 && !searchValueValid, highlighted: highlightedOption === i, @@ -332,7 +335,7 @@ whenever(isOpen, async () => { {{ option }} - +