Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Duplicate Selected Pills in Multi-Select Component #99

Closed
ayush-kr-tra opened this issue Jan 10, 2025 · 1 comment
Closed

Fix Duplicate Selected Pills in Multi-Select Component #99

ayush-kr-tra opened this issue Jan 10, 2025 · 1 comment
Assignees

Comments

@ayush-kr-tra
Copy link

ayush-kr-tra commented Jan 10, 2025

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…

@ayush-kr-tra ayush-kr-tra self-assigned this Jan 10, 2025
@ayush-kr-tra
Copy link
Author

Closing this issue, As I can see the there already a PR Fixing this issue - #84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant