DEV: Add select-kit option to hide values from preview (#18002)
* DEV: Add select-kit option to hide values from preview
This commit is contained in:
parent
36f766399d
commit
ce30422d6c
|
@ -125,5 +125,26 @@ module(
|
|||
"it forces the max length of the tag"
|
||||
);
|
||||
});
|
||||
|
||||
test("values in hiddenFromPreview will not display in preview", async function (assert) {
|
||||
this.set("value", ["foo", "bar"]);
|
||||
this.set("hiddenValues", ["foo"]);
|
||||
|
||||
await render(
|
||||
hbs`<MiniTagChooser @options={{hash allowAny=true hiddenValues=this.hiddenValues}} @value={{this.value}} />`
|
||||
);
|
||||
assert.strictEqual(
|
||||
query(".formatted-selection").textContent.trim(),
|
||||
"bar"
|
||||
);
|
||||
|
||||
await this.subject.expand();
|
||||
assert.deepEqual(
|
||||
[...queryAll(".selected-content .selected-choice")].map((el) =>
|
||||
el.textContent.trim()
|
||||
),
|
||||
["bar"]
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -59,7 +59,13 @@ export default MultiSelectComponent.extend(TagsMixin, {
|
|||
}),
|
||||
|
||||
content: computed("value.[]", function () {
|
||||
return makeArray(this.value).map((x) => this.defaultItem(x, x));
|
||||
let values = makeArray(this.value);
|
||||
if (this.selectKit.options.hiddenValues) {
|
||||
values = values.filter(
|
||||
(val) => !this.selectKit.options.hiddenValues.includes(val)
|
||||
);
|
||||
}
|
||||
return values.map((x) => this.defaultItem(x, x));
|
||||
}),
|
||||
|
||||
search(filter) {
|
||||
|
|
|
@ -293,6 +293,7 @@ export default Component.extend(
|
|||
placementStrategy: null,
|
||||
mobilePlacementStrategy: null,
|
||||
desktopPlacementStrategy: null,
|
||||
hiddenValues: null,
|
||||
},
|
||||
|
||||
autoFilterable: computed("content.[]", "selectKit.filter", function () {
|
||||
|
|
Loading…
Reference in New Issue