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

Select Component: Selecting same choice twice clears selection #1622

Closed
bigmac44 opened this issue Jan 14, 2025 · 5 comments
Closed

Select Component: Selecting same choice twice clears selection #1622

bigmac44 opened this issue Jan 14, 2025 · 5 comments
Labels
status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: enhancement An improvement or enhancement to an existing feature

Comments

@bigmac44
Copy link

bigmac44 commented Jan 14, 2025

Describe the bug

Choosing the same option twice in a <Select> deselects the option on next.shadcn-svelte.com.

This behavior is contrary to how the original shadcn and non-next shadcn-svelte work.

It looks like the issue can be fixed by explicitly setting allowDeselect={false} on the <Select.Root> object, but this should be the default to be consistent.

Reproduction

You can see the problem on the next.shadcn-svelte.com site.

https://next.shadcn-svelte.com/docs/components/select

Just select Banana twice in the first example and compare the behavior with the original Shadcn or the non-next shadcn-svelte.

https://ui.shadcn.com/docs/components/select
https://shadcn-svelte.com/docs/components/select

Logs

No response

System Info

Visible on shadcn-svelte website

Severity

annoyance

@huntabyte huntabyte added status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: enhancement An improvement or enhancement to an existing feature labels Jan 14, 2025
@shyakadavis
Copy link
Contributor

@huntabyte was about to open a P.R for this, but wondering if it's better to have the default in bits-ui or just here? WDYT?

@huntabyte
Copy link
Owner

Likely the default in Bits tbh so it aligns with a regular select, but open to ideas!

@shyakadavis
Copy link
Contributor

I'll be honest, for some reason, my intuition is that if I click on an already selected item, it should deselect. Matter of fact, I constantly find myself fighting with some selects trying to revert (either I clicked by mistake the first time, or something...) and the only resolution is for me to reload the page. Ergo, I really appreciate the current default of allowDeselect={true}.

But this could be just me. Wonder what others think about this.

@ieedan
Copy link
Contributor

ieedan commented Jan 15, 2025

I suppose with the default behavior of select being no deselect in the browser it may make more sense for the default to be false.

I think it really depends on the situation but most of the time when I find myself wanting something to be deselect-able what I really want is multi-select.

@shyakadavis
Copy link
Contributor

I believe this was addressed in huntabyte/bits-ui#1049

@bigmac44 kindly confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: enhancement An improvement or enhancement to an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants