jjimenezshaw / Leaflet.Control.Layers.Tree

a Tree Layers Control for Leaflet
https://jjimenezshaw.github.io/Leaflet.Control.Layers.Tree/examples/basic.html
BSD 3-Clause "New" or "Revised" License
146 stars 36 forks source link

potential bug in selectAllCheckbox #62

Open cspence001 opened 2 years ago

cspence001 commented 2 years ago

I have a layer control tree with selectAllCheckbox set to true for subgroups of child layers. I noticed a bug that could be in part due to my app configuration. All computable reference layers are acknowledged in the tree but the data for each is loaded in separately based on user requests. I noticed it happens that if I select a layer in the tree for data that has not yet been loaded, I get the obvious error Cannot read properties of undefined (reading 'options') - and subsequently after selecting/deselecting the selectAllCheckbox for layers that with data that had been added in and previously had not presented to be a problem that it will only compute one layer at a time - either deselecting one until none, or switching one sole layer on back and forth - with the error of Uncaught TypeError: Cannot read properties of undefined (reading 'parentNode').

Perhaps the solution is that theses children within the selectAllCheckbox subGroups need to be referenced in a separate 'overlayadd' 'overlayremove' function as a group? I do not have an issue with the selectAllCheckbox if the data is all loaded in, it only seems to occur when I have selected a ghost layer (no data underneath) and go on to select/deselect options that are available.