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

Make bind:group work the same as bind:value={get, set}. #15537

Closed
thebjorn opened this issue Mar 18, 2025 · 0 comments
Closed

Make bind:group work the same as bind:value={get, set}. #15537

thebjorn opened this issue Mar 18, 2025 · 0 comments

Comments

@thebjorn
Copy link

Describe the problem

The syntax for bind:group is different from the syntax for bind:value with a get, set tuple for no apparent reason...?

For the bind:group case you need to create a facade object which get/sets a name:

<script>
    let val = $state("2");
    const facade = {
      get val() { return val; },
      set val(v) { val = v; },
    };
</script>

<label><input type="radio" value="1" bind:group={facade.val}> one</label>
<label><input type="radio" value="2" bind:group={facade.val}> two</label>

<input bind:value={() => val, v => val = v}>

Describe the proposed solution

It would be great if bind:group={() => val, v = > val = v} would work the same way as it does for bind: value.

It would be even better if the tuple could be passed as a value, i.e. without being destructured:

<input type="radio" bind:group={form_context.get_accessor('name')} ...>

Importance

nice to have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants