N00ts/vue3-treeview

`checkMode auto` skips some children when checking an item while its not opened

robertklep opened this issue · 6 comments

The issue can be demonstrated with one of your demo's: https://codesandbox.io/s/confogiration-umz56

Enable "Checkboxes" and "Checkmode auto", make sure the text1 node is closed, then check it.

When you open it, you'll see that the first nodes of text11 and text13 will not be checked:

image

This behaviour is consistent, I noticed it when trying to implement a tree view for my own project.

When text1 is opened, then checked, everything works.

EDIT: a related issue: when you close text1 and reopen it, text11 and text13 will be in an unchecked state (so not indeterminate anymore):

image

Looks like there's a race condition between recurseDown and the watchers in useCheckBox.

I managed to fix this particular issue by using post flushing on the watchers, but this introduces other issues :(

N00ts commented

If you find the issue, don't hesitate to fix it. I will try to take a look but unfortunately I am very busy right now

N00ts commented

I just published a new version (0.3.6) that should fix the issue. You can update the demo :)

@N00ts sadly, this introduces an issue that I also ran into (and haven't been able to fix yet).

Steps to show the issue:

  • enable "Checkboxes" and "Checkmode auto"
  • check "text1"
  • open "text1" (which shows the initial issue is now fixed)
  • open "text11"
  • uncheck "id111"

The state will look like this:
image

Then:

  • close "text1"
  • open "text1" again

The state now looks like this:

image

So "text11" should have been indeterminate but by closing "text1" it went to "unchecked", as are its children.

N00ts commented

Thank you for the feedback it should be fixed with version 0.3.7 :)

Awesome! I haven't tested extensively yet but it looks like it works as expected now 🥳