Skip to content

fix(desktop): New File on a collapsed sidebar folder expands it - #4809

Merged
Jocs merged 1 commit into
developfrom
fix/3439-collapsed-folder-newfile
Jul 2, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/3439-collapsed-folder-newfile

Conversation

@Jocs

@Jocs Jocs commented Jul 1, 2026

Copy link
Copy Markdown
Member

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"). handleInputFocus guarded the expand (isCollapsed = false) behind if (input.value), but input.value is null while 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 handleInputFocus to 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

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]>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Build artifacts for PR #4809:

Run: https://github.com/marktext/marktext/actions/runs/28511345463

Artifact Size Link
marktext-macos-x64 293.0 MB Download
marktext-windows-arm64 275.7 MB Download
marktext-macos-arm64 282.7 MB Download
marktext-linux 627.5 MB Download
marktext-windows-x64 283.8 MB Download

@Jocs
Jocs merged commit 9ca5ccf into develop Jul 2, 2026
10 checks passed
@Jocs
Jocs deleted the fix/3439-collapsed-folder-newfile branch July 2, 2026 13:18
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.

failed to new file | 新建文件失败

1 participant