Skip to content

Commit dcf0c7e

Browse files
committed
fix(multi-select): invalid/warn, filterable variant should only render one icon
1 parent 7aad141 commit dcf0c7e

2 files changed

Lines changed: 30 additions & 8 deletions

File tree

src/MultiSelect/MultiSelect.svelte

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -665,14 +665,6 @@
665665
{id}
666666
{name}
667667
>
668-
{#if invalid}
669-
<WarningFilled class="bx--list-box__invalid-icon" />
670-
{/if}
671-
{#if !invalid && warn}
672-
<WarningAltFilled
673-
class="bx--list-box__invalid-icon bx--list-box__invalid-icon--warning"
674-
/>
675-
{/if}
676668
{#if value}
677669
<ListBoxSelection
678670
on:clear={() => {

tests/MultiSelect/MultiSelect.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,36 @@ describe("MultiSelect", () => {
678678
expect(wrapper).toHaveClass("bx--multi-select--invalid");
679679
});
680680

681+
// Regression: filterable + invalid rendered two WarningFilled icons
682+
it("renders only one invalid icon when filterable", () => {
683+
const { container } = render(MultiSelect, {
684+
props: {
685+
items,
686+
filterable: true,
687+
invalid: true,
688+
invalidText: "Invalid selection",
689+
},
690+
});
691+
692+
const icons = container.querySelectorAll(".bx--list-box__invalid-icon");
693+
expect(icons).toHaveLength(1);
694+
});
695+
696+
// Regression: filterable + warn rendered two WarningAltFilled icons
697+
it("renders only one warning icon when filterable", () => {
698+
const { container } = render(MultiSelect, {
699+
props: {
700+
items,
701+
filterable: true,
702+
warn: true,
703+
warnText: "Warning message",
704+
},
705+
});
706+
707+
const icons = container.querySelectorAll(".bx--list-box__invalid-icon");
708+
expect(icons).toHaveLength(1);
709+
});
710+
681711
it("handles warning state", () => {
682712
render(MultiSelect, {
683713
props: {

0 commit comments

Comments
 (0)