Skip to content

Fix Duplicate Selected Pills in Multi-Select Component #99

@ayush-kr-tra

Description

@ayush-kr-tra

This behavior has been observed when we are selecting a option
which are present in two different groups, The Pills are shown twice.

Engineering Notes:
The issue lies in the logic for filtering and creating pills in the multi-select component. The duplicate selection occurs because duplicate values in the input array are not handled.

Current implementation:

// Create new pills.
const pillsToCreate: string[] = values.filter( ( value: string ) => ! pillValues.includes( value ) );

Proposed fix:

// Create new pills.
const pillsToCreate: string[] = Array.from(new Set(values)) // Ensure Unique values.
.filter( ( value: string ) => ! pillValues.includes( value ) );

Impacted File
web-components/src/multi-select/tp-multi-select-pills.ts

Uploading Screenshot 2025-01-09 at 3.17.36 PM.png…

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions