Skip to content

Fix nodes disappearing after closing a node with an ancestor sibling#103

Merged
paolosimone merged 1 commit into
mainfrom
fix-broken-tree-state
Oct 12, 2025
Merged

Fix nodes disappearing after closing a node with an ancestor sibling#103
paolosimone merged 1 commit into
mainfrom
fix-broken-tree-state

Conversation

@paolosimone
Copy link
Copy Markdown
Owner

Refactored the logic in the TreeState.close method to use a new helper function, findNextSibling, for determining the next node after closing. This makes the sibling-finding logic more robust by walking up the parent chain until a sibling is found, rather than just checking immediate siblings or parent siblings.

@paolosimone paolosimone requested a review from Copilot October 12, 2025 09:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where nodes were disappearing after closing a node with an ancestor sibling by improving the sibling-finding logic in the TreeState.close method. The fix introduces a more robust approach that traverses up the parent chain to find the next appropriate sibling node.

  • Replaced inline sibling-finding logic with a dedicated helper function findNextSibling
  • Updated test data to use array values instead of primitive values in the object_array structure

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
extension/src/viewer/components/TreeViewer/Tree/TreeState.ts Added findNextSibling helper function and refactored the close method to use it for more robust sibling detection
samples/test.json Updated test data structure to use arrays as values in object_array entries

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@paolosimone paolosimone merged commit cfb5a13 into main Oct 12, 2025
@paolosimone paolosimone deleted the fix-broken-tree-state branch October 12, 2025 09:10
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.

Closing the last element inside a list makes subsequent elements disappear

2 participants