fix(app): allow collapsing parent folder of selected file in explorer#500
Merged
fix(app): allow collapsing parent folder of selected file in explorer#500
Conversation
The file explorer had a useEffect that re-enforced expansion of every ancestor of `selectedEntryPath` whenever `expandedPaths` changed. As a result, the moment a user collapsed the parent folder of a file they had just opened, the effect re-added that folder to the expanded set and the folder appeared stuck open. Selection and expansion are orthogonal: clicking a file should not dictate that its parent folder stays open forever. There is also no current caller that sets `selectedEntryPath` from outside the tree, so the reveal-on-external-selection use case the effect was designed for is unused. Delete the effect and its two now-dead helpers. If a future "Reveal in Explorer" action is introduced, it can expand ancestors at the call site. Adds an E2E regression test that reproduces the original scenario: expand a folder, open an image, collapse the parent folder, assert children are hidden. Also asserts an unrelated sibling folder still expands after the image is open, guarding against any future regression that makes the bug global.
668d086 to
3fe755d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useEffectinfile-explorer-pane.tsxthat re-enforced expansion of the selected file's ancestor directories on everyexpandedPathschange. The effect was responsible for the bug where clicking an already-expanded parent folder of a recently-opened file did nothing — the effect immediately re-added the folder toexpandedPaths.selectedEntryPathfrom outside the tree, so the reveal-on-external-selection use case the effect was designed for is unused. A future "Reveal in Explorer" action can expand ancestors at the call site.getParentDirectory,getAncestorDirectories) that had no other consumers.Test plan
npm run test:e2e --workspace=@getpaseo/app -- file-explorer-collapse.spec.ts— 1 passed.public/og.pngscenario after hard-reload. Parent folder now collapses correctly; unrelated folders still toggle; non-image file open still works.