Skip to content

Update bind:group when the binded input is removed #13005

@hyunbinseo

Description

@hyunbinseo

Describe the problem

bind:group can be out of sync with the DOM when the binded input elements are removed.

<script lang="ts">  let selectedItems = ['a', 'b', 'c'];  let items = ['a', 'b', 'c'];  $: console.log(selectedItems); </script> <!-- This does not update the selectedItems array. --> <!-- Expected: selectedItems becomes [] and is logged. --> <button type="button" on:click={() => (items = [])}>Remove all items</button> {#each items as item (item)} <label> <input type="checkbox" value={item} bind:group={selectedItems} /> <span>{item}</span> </label> {/each}

https://svelte.dev/repl/96dcce0d2426459c9a08c0fdc105a246?version=4.2.19

Describe the proposed solution

Update bind:group array when the binded input elements are removed

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions