dgreene1 / react-accessible-treeview

A react component that implements the treeview pattern as described by the WAI-ARIA Authoring Practices.
https://dgreene1.github.io/react-accessible-treeview
MIT License
277 stars 37 forks source link

Crashes with `Node with id=[object Object] doesn't exist in the tree.` with adding nested data #178

Closed bnovc closed 4 months ago

bnovc commented 6 months ago

If you use your example on https://dgreene1.github.io/react-accessible-treeview/docs/examples-MultiSelectCheckboxAsync, but you change it to have nested elements, you get the crash without many clues

Node with id=[object Object] doesn't exist in the tree.
          updateTreeData(value, element.id, [
            {
              name: `Child Node ${value.length}`,
              children: [
                {
                name: `Sub Child Node ${value.length}`,
                children: [],
                id: value.length+2,
                parent: value.length
                },
              ],
              id: value.length,
              parent: element.id,
              isBranch: true,
            },
            {
              name: "Another child Node",
              children: [],
              id: value.length + 1,
              parent: element.id,
            },
          ])

I think it would help a lot to include source maps in the distribution to help debug these things.

bnovc commented 6 months ago

Note also the flattened approach doesn't work - it puts these three all on the same level

            {
              name: `Child Node ${value.length}`,
              children: [
              ],
              id: value.length,
              parent: element.id,
              isBranch: true,
            },
            {
              name: "Another child Node",
              children: [],
              id: value.length + 1,
              parent: element.id,
            },
            {
                name: `Sub Child Node ${value.length}`,
                children: [],
                id: value.length+2,
                parent: value.length
            },
dgreene1 commented 6 months ago

We welcome a PR for this.

stale[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 months ago

This issue was closed automatically since it was marked as stale because it has not had recent activity. Thank you for your contributions.