Skip to content

Deleting characters in search input leads to unexpected results #73

@Meas

Description

@Meas

ISSUE:
I have noticed that when deleting characters from the searchValue, unexpected filtering happens which can also be reproduced on the official demo page.

Steps to reproduce:

1.) Go to https://shadcn-multi-select-component.vercel.app/
2.) Click the very first multiselect and type "n" - the list should be updated to display 3 labels: "Next.js", "Nuxt.js" and "Angular" - as expected
3.) Now type the letter "e", so the search input should be "ne" - the list should display "Next.js" only - again as expected
4.) When we remove the letter "e" and now end up with search input as "n" again instead of getting "Next.js", "Nuxt.js" and "Angular", we instead get only "Next.js"

Cause:
I lost a couple of hours thinking my modifications cause this, but ended up being simply shenanigans regarding the internal logic of the Command component, or more precisely the "cmdk" package how it interacts with this multiselect.

FIX:
The simplest fix is just to find the command tag and add the following:
<Command shouldFilter={false}>

Hope this helps somebody and maybe address it in some update.
Thanks for the read and thanks for the component!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions