bumbeishvili / org-chart

Highly customizable org chart. Integrations available for Angular, React, Vue
https://stackblitz.com/edit/web-platform-o5t1ha
MIT License
928 stars 330 forks source link

Application crashing when expanding/collapsing all nodes in tree #272

Open hsanchez7934 opened 1 year ago

hsanchez7934 commented 1 year ago

Describe the bug

I have found a bug where I am not able to exit recursive methods setExpansionFlagToChildren & expandSomeNodes when attempting to expand/collapse the entire tree.

This seems to happen when the org chart data is linear: each node has exactly one parent and one child.


I have set up two code repos to demonstrate this bug

The following repo has a possible bug fix:

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/org-chart-recursion-bug-fix-xr9kpo
  2. Wait for iframe to load & for single card to render
  3. Click Expand All button
  4. Click Collapse All button

Note: The tree expands and collapses as expected without crashing the application. We're able to exit out of recursive methods.


The following repo successfully reproduces the bug:

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/org-chart-recursion-bug-xl71fy
  2. Wait for iframe to load & for single card to render
  3. Click Expand All button
  4. Click Collapse All button

Note: The application crashes as we're never able to exit recursive methods.


Expected behavior

I am expecting to be able to collapse and expand entire tree without crashing the application. I am expecting to be able to exit recursive methods successfully.

Desktop:


Original written methods:

original1 original2

Refactored methods with possible bug fix:

refactored1 refactored2

hsanchez7934 commented 1 year ago

Greetings, I wanted to follow up and check the status of this bug/issue? and to see if there is a possibility of patching this bug?

bumbeishvili commented 1 year ago

Hi, no, don't plan to address this issue in the near future. I am not exactly sure if the new code fixes the issue too (haven't checked & thought about possible implications)

I'd suggest taking the code as it is and modifying it for your use case

hsanchez7934 commented 1 year ago

Appreciate the prompt response!