Repository navigation
fix(desktop): New File on a collapsed sidebar folder expands it - #4809
Merged
Merged
Conversation
Invoking "New File" on a collapsed folder did nothing. The create input only renders inside the folder's expanded contents, but handleInputFocus guarded the expand (isCollapsed = false) behind `if (input.value)` — which is null while collapsed — so the folder never expanded and no input appeared. Scope the handler to the create-target folder and expand it first, then focus the input on the next tick once it has rendered. Fixes #3439 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Problem
Invoking New File (sidebar context menu) on a collapsed folder did nothing — no name input appeared, so no file could be created.
Root cause
The create
<input>only renders inside the folder's expanded contents (v-if="!isCollapsed").handleInputFocusguarded the expand (isCollapsed = false) behindif (input.value), butinput.valueisnullwhile the folder is collapsed (the input isn't in the DOM yet), so the folder never expanded and the input never appeared. The handler also ran on every tree-folder without checking which one was the create target.Fix
Scope
handleInputFocusto the create-target folder (createCache.dirname === folder.pathname), expand it first, then focus the input on the next tick once it has rendered.Test
packages/desktop/test/e2e/new-file-collapsed-folder-3439.spec.ts(real built app): drives the real context-menu → bus → store → tree-folder path (injecting the "New File" menu click) on a collapsed folder and asserts the create input becomes visible. Verified RED→GREEN; existing sidebar e2e still pass.Fixes #3439
🤖 Generated with Claude Code