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

bind:group on nested loop not working as expected #5811

Closed
axmad386 opened this issue Dec 19, 2020 · 2 comments · Fixed by #5835
Closed

bind:group on nested loop not working as expected #5811

axmad386 opened this issue Dec 19, 2020 · 2 comments · Fixed by #5835

Comments

@axmad386
Copy link

bind:group on input checkbox not working as expected inside nested loop

Describe the bug
Currently I create dynamic checkbox based on nested array. I want to make role management with just check the action (C,R,U,or D) based on module. This is the minimal example of the data

[
  {
     key: "p1",
     checked: [],
     sub: [
      {
         key: "p1s1",
	checked: []
     }]
  },
 {
    key: "p2",
    checked: [],
    sub: [
     {
	key: "p1s1",
	checked: []
     }]
 }
]

p1 will be parent module, and p1s1 is sub module for p1. Then i loop that array to create input checkbox. For parent checkbox the behaviour is ok as expected. But for the nested one is not working as expected. I think the index of bind:group of nested checkbox is collapse with the other.
For example:
p1s1 has checked value ["C"], when I check "R" on p2s1 (same sub index but different parent), the value of p2s1 checked is ["C","R"].

To Reproduce
this is the REPL link for the demo https://svelte.dev/repl/8d03a86642e449108c2dd22de7aa8cd3?version=3.31.0

  1. check p1s1 C
  2. check p2s1 R
    you will see, p2s1 C is checked (if you check p1s1 D first, you will see p2s1 D checked)

Expected behavior
only p2s1 R is checked

Stacktraces
If you have a stack trace to include, we recommend putting inside a <details> block for the sake of the thread's readability:

Stack trace

Stack trace goes here...

Information about your Svelte project:
To make your life easier, just run npx envinfo --system --npmPackages svelte,rollup,webpack --binaries --browsers and paste the output here.

System:
OS: macOS 11.0.1
CPU: (4) x64 Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
Memory: 212.89 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.4.0 - ~/.nvm/versions/node/v14.4.0/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 6.14.5 - ~/.nvm/versions/node/v14.4.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Chrome: 87.0.4280.88
Firefox: 83.0
Safari: 14.0.1
npmPackages:
rollup: ^2.3.4 => 2.33.1
svelte: ^3.31.0 => 3.31.0

Severity
Not urgent, but is annoying

Current Work around
when i change bind:group on nested loop from s.checked to d.sub[i].checked this issue is gone

@Conduitry
Copy link
Member

This is fixed in 3.31.1 - https://svelte.dev/repl/8d03a86642e449108c2dd22de7aa8cd3?version=3.31.1

@axmad386
Copy link
Author

axmad386 commented Jan 6, 2021

Whoa thank you for fix, that's awesome 👍

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

Successfully merging a pull request may close this issue.

2 participants