N00ts / vue3-treeview

a simple treeview in vue js 3
MIT License
73 stars 65 forks source link

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

Closed robertklep closed 2 years ago

robertklep commented 2 years ago

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
robertklep commented 2 years ago

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 2 years ago

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 2 years ago

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

robertklep commented 2 years ago

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

Steps to show the issue:

The state will look like this:

image

Then:

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 2 years ago

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

robertklep commented 2 years ago

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