Comments (7)
@olegpolin Yeah, this is because it is being registered as an "outside click" followed by a "click." Clicking the label is outside the content, causing the content to close, and then the label triggers a click on the button, which reopens it.
I'll look into getting this resolved in the Svelte 5 version of Bits I'm currently working on.
from shadcn-svelte.
Hmm... isn't this the native/expected behaviour?
When a user clicks or touches/taps a label, the browser passes the focus to its associated input (the resulting event is also raised for the input). That increased hit area for focusing the input provides an advantage to anyone trying to activate it — including those using a touch-screen device.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
If you don't want this behaviour, remove the for="options"
but that just leads to poor U/X in my opinion. 🤷♂️
from shadcn-svelte.
Native behavior with a <label>
associated with a <select>
doesn't actually open the select, it should just pass the focus to the select element, as far as I can tell.
It seems like the <Select>
component in shadcn-svelte is actually a button with a popover, which helps explain the abnormal behavior.
from shadcn-svelte.
Hunh, you're right.
TIL: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
But still, removing the for
in your attached repro rids one of this behaviour.
Also, re-reading your issue, I can finally see the "not closing" it part. And I agree, it feels odd/wrong.
Maybe Hunter will provide some context.
from shadcn-svelte.
So, when a label is associated with a button, the only option when clicking said label is to "click" the button.
I tried researching to see if there is a way to determine if the 'click' event came from a select and came up empty-handed.
from shadcn-svelte.
The weirder issue is that clicking the label again doesn't close the select, but closes it and reopens it, as if it is being clicked twice (at least on chrome on windows)
from shadcn-svelte.
Got it, thanks
from shadcn-svelte.
Related Issues (20)
- `npx shadcn-svelte@latest init` does not recognise `$lib/components` as aliased in SvelteKit. HOT 5
- Wrong access to plugin states pagination attribute HOT 2
- isVisible is not an exported Prop of Pagination.Item HOT 3
- Bug in Example Task Page HOT 2
- On this Page section of docs not scrollable
- ScrollArea.ScrollBar missing in firefox HOT 2
- .
- Cryptic css rules needed to get out-of-the-box results HOT 1
- Resizable abstraction leaks when importing type PaneAPI HOT 1
- Janky animation on Edge browser with high resolution monitor HOT 1
- bug: page scrolls when some components are closed after opening them
- Horizontal Scrolling not working on chrome desktop HOT 8
- Web component option
- Adding a input otp component HOT 11
- Time Picker
- Basic install breaks tailwind HOT 2
- DateTicker Localization(l18n) setting HOT 1
- Data table becomes empty when email column removed HOT 3
- Data Table "On this page" is missing Row Selection HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shadcn-svelte.