Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not error when data has nodes removed that are expanded #174

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

blittle
Copy link
Contributor

@blittle blittle commented Feb 1, 2024

We use react-accessible-treeview at Shopify along with folder/file search. With our implementation the rendered nodes change based on the search query. We also want the nodes to default to being expanded. As shown with the included test, TreeView breaks when re-rendered where both the data and expandedIds props change.

The problem is that the previous expandedIds data is stored, and the difference is calculated. But an ID should not be included in the difference if that ID doesn't still exist in the data. As I see it, there are two solutions:

  1. If the id is not found in the data, ignore it. That's what's implemented in this PR, inspired by Fix a bug with node deletion #132
  2. Change the difference function to take the tree data as a param, and only add an ID to the diff if it's still in the data tree.

This resolves #133

I think I have a workaround by never removing nodes from the tree, and instead adding a boolean to the metadata whether or not it should be displayed.

Copy link

stale bot commented Apr 9, 2024

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 stale bot added wontfix This will not be worked on and removed wontfix This will not be worked on labels Apr 9, 2024
@blittle
Copy link
Contributor Author

blittle commented Apr 12, 2024

I'm happy to update the PR in any way if necessary to get it merged. Thank you in advance.

@dgreene1
Copy link
Owner

@blittle I’ve asked my team to look at it

Copy link

stale bot commented Jun 14, 2024

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 stale bot added the wontfix This will not be worked on label Jun 14, 2024
Copy link

stale bot commented Jun 22, 2024

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

@stale stale bot closed this Jun 22, 2024
@mihna123
Copy link

Why was this closed? I think this is a fine solution to issue #133

@dgreene1
Copy link
Owner

Stalebot closed it. I’ll reopen it.

@dgreene1 dgreene1 reopened this Jun 26, 2024
@stale stale bot removed wontfix This will not be worked on labels Jun 26, 2024
@camplowell
Copy link

I'd really love to see this get merged. Working around it from outside the library is proving to be a very convoluted process.

@TylerAHolden
Copy link

Would like to see this merged as well. I'm trying to save expanded state when watching a filesystem folder, so if a subfolder is deleted on the OS and the expandedId was saved in local state then it errors because the node doesn't exist in the tree anymore. A "quiet" failure is expected for my use-case. I would expect just like this PR fixes, the node is ignored.

Copy link

stale bot commented Oct 26, 2024

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 stale bot added the wontfix This will not be worked on label Oct 26, 2024
@stale stale bot removed the wontfix This will not be worked on label Oct 26, 2024
@dgreene1
Copy link
Owner

@yhy-1, @mellis481, seems like we have a lot of interest here. Is this PR up to snuff? I believe we have an internal tracking ticket to review this. Not sure if it’s been prioritized. But I’m commenting to keep stalebot from closing it.

Copy link

stale bot commented Dec 25, 2024

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 stale bot added the wontfix This will not be worked on label Dec 25, 2024
Copy link

stale bot commented Jan 1, 2025

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

@stale stale bot closed this Jan 1, 2025
@benalbrecht
Copy link

I'd love to see this get merged, please reopen.

@dgreene1 dgreene1 reopened this Jan 7, 2025
@stale stale bot removed the wontfix This will not be worked on label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug with node deletion when controlling node expansion
6 participants