GithubHelp home page GithubHelp logo

Comments (8)

huntabyte avatar huntabyte commented on June 3, 2024 1

Good news, I identified the issue and am working on a patch for it now!

from bits-ui.

JYLN avatar JYLN commented on June 3, 2024 1

@huntabyte The issue with select is confirmed fixed within this minimal repro I was working up to open a separate issue on! 🎉

https://stackblitz.com/edit/github-lsakyy

Genuinely appreciate all you do for the Svelte community!

from bits-ui.

huntabyte avatar huntabyte commented on June 3, 2024

This issue would fall back to https://github.com/huntabyte/bits-ui, so will move it there

from bits-ui.

JustDenP avatar JustDenP commented on June 3, 2024

@huntabyte Thank you, also form selector component in shadcn is broken with bits-ui 0.9.2 and can't be opened at all. You can check it in docs with form example. https://www.shadcn-svelte.com/docs/components/select#form

Version 0.9.1 works fine for me.

from bits-ui.

huntabyte avatar huntabyte commented on June 3, 2024

hm I do see that now that you mention in 🤔

from bits-ui.

huntabyte avatar huntabyte commented on June 3, 2024

Also, onOpenChange is intended to be used for internal changes that are out of your control, and actually the logic of updating your bind:open is handled there. So when you change it outside of it, it would end up calling it twice which I expect you wouldn't want.

from bits-ui.

huntabyte avatar huntabyte commented on June 3, 2024

The issue I'm referring to is for the select btw.

As mentioned, the onOpenChange couldn't work the way you expect it to due to how it synchronizes the bind state with the internal state. onOpenChange is designed to be used when you aren't controlling the state from outside the component with bind:open.

Otherwise, it results in behavior like this, where the change function is fired multiple times, once when it changes, and a second time when it syncs the value.

CleanShot.2023-11-09.at.20.20.29.mp4

I could possibly explore some alternative approaches to this, but is very low on my priority list at the moment.

The idea is that if you are modifying the state outside the component, you know when it is going to change and should apply whatever logic you expect to happen on change there for the time being.

from bits-ui.

huntabyte avatar huntabyte commented on June 3, 2024

Going to close this issue now as the behavior is working as initially intended, maybe in the future during a refactor (maybe svelte 5) we will be able to accommodate this, but at the moment the juice isn't worth the squeeze!

from bits-ui.

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.