-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
Description
Describe the bug
bind:group should only add or remove the single value that its element contains.
However, when updating an element in a nested {#each} block, it will clear any values added from other child {#each} blocks.
In the linked REPL:
- Select "1a"
- Select "2a"
- Expected output should be ["1a", "2a"]
- Actual output is ["2a"]
For anyone else running into this issue, this can be worked around in the meantime by using a manual onchange handler
import type { ChangeEventHandler } from "svelte/elements";
const onchange: ChangeEventHandler<HTMLInputElement> = ({ currentTarget }) => {
if (currentTarget.checked) {
group = [...group, currentTarget.value];
} else {
const index = group.indexOf(currentTarget.value);
if (index !== -1)
group = [...group.slice(0, index), ...group.slice(index + 1)];
}
};Reproduction
Bugged Svelte 5 REPL (Workaround)
Working Svelte 4 REPL
Logs
No response
System Info
N/ASeverity
annoyance
JetLua