Git Product home page Git Product logo

Comments (7)

huntabyte avatar huntabyte commented on July 16, 2024 1

@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.

shyakadavis avatar shyakadavis commented on July 16, 2024

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.

olegpolin avatar olegpolin commented on July 16, 2024

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.

shyakadavis avatar shyakadavis commented on July 16, 2024

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.

huntabyte avatar huntabyte commented on July 16, 2024

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.

olegpolin avatar olegpolin commented on July 16, 2024

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.

olegpolin avatar olegpolin commented on July 16, 2024

Got it, thanks

from shadcn-svelte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.