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

fix: module tree expansion state when closing the module of the selected decl #3022

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

deniseli
Copy link
Contributor

@deniseli deniseli commented Oct 7, 2024

Fixes: #2982

This fix delves into the nuance of component re-rendering lifecycle a bit. Basically, before, we would add the selected module to local storage AND update the component state on every single re-render of the component (at const [expandedModules, setExpandedModules] = useState(...). The problem with that was that when we toggled the selected module to close it, the re-render would cause the selected module to still be added back to local storage, but the component state would be out of sync. Then when you went to expand that module again, because the states got unsynced, it would stay stuck in the visibly-closed state. Now, we only add the selected module to local storage in the effect, which doesn't get triggered on toggle a module's expansion state. As a result, the state doesn't de-sync.

So now, you can do the following:

  1. Select a decl
  2. Close the module of the selected decl in the module tree
  3. Re-expand that same module in the module tree. It works.

While the following still works correctly:

  1. Close all the modules (i.e. to-be-selected module will not be cached as expanded)
  2. Go to a decl page (e.g. paste a link into the browser)
  3. The selected module should be expanded in the tree.

@deniseli deniseli requested a review from a team as a code owner October 7, 2024 18:43
@deniseli deniseli requested review from wesbillman and removed request for a team October 7, 2024 18:43
This was referenced Oct 7, 2024
Copy link
Collaborator

@wesbillman wesbillman left a comment

Choose a reason for hiding this comment

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

Awesome thanks!!

@deniseli deniseli merged commit 5b03801 into main Oct 7, 2024
98 checks passed
@deniseli deniseli deleted the dli/bug branch October 7, 2024 19:11
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.

console modules tree cannot re-open group containing selected node
2 participants