fix: focus the editor after creating Markdown notes - #278
Conversation
|
@n00ki is attempting to deploy a commit to the bholmesdev's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Overview
Restores Markdown editor focus after intentional note creation without focusing on ordinary navigation. Cmd+N / menu / palette go through focusMarkdownEditorAfterRender; sidebar new-note Enter reports { origin, commit } and desktop focuses only after a successful rename. HTML create, blur commits, existing renames, and path changes stay on prior focus behavior. Solid race guard (currentPath check) and useful unit coverage.
Concerns
- No blocking issues.
- Sidebar tests assert rename metadata, not the
handsOffFocusside effect (tree not focused). Optional follow-up.
Comments audit
fileActions.test.ts/Sidebar.test.tsx: vitest env + existing@ts-expect-errorpattern only. No new prose comments to flag.- Unchanged path-rewrite comments left intact.
Tests audit
fileActions.test.ts: success focus, failed create, navigation race — good.Sidebar.test.tsx: Enter origin/commit for new-note / rename / new-html — matches the desktop contract.renameMarkdownFilereturn value asserted.
Verdict
Found: 0 critical, 0 important, 1 suggestion
Approve with nits
Reviewed by a Warp Factory agent.
| "/workspace/new-file.md", | ||
| "daily-notes", | ||
| { origin: "new-note", commit: "enter" }, | ||
| ); |
There was a problem hiding this comment.
💡 [SUGGESTION] This only checks onRenameFile args. The regression risk is handsOffFocus skipping navRef.focus() / pendingFocusDisplayPath on new-note Enter. Assert document active element stays off the tree (or that nav is not focused) after submit so that handoff cannot regress silently.
There was a problem hiding this comment.
Overview
Follow-up review of focus-after-create for Markdown notes. Cmd+N / menu / palette still go through focusMarkdownEditorAfterRender after successful create; sidebar new-note Enter reports { origin, commit } and desktop focuses only after a successful rename. HTML create, blur commits, existing renames, and ordinary navigation keep prior focus behavior.
Follow-up status
- Prior suggestion (assert
handsOffFocusskips tree focus): addressed. New-note Enter test spiestree.focus, flushes mocked rAF, and expects no tree focus.
Concerns
- No blocking issues in the delta or remaining PR surface.
Comments audit
fileActions.test.ts/Sidebar.test.tsx: vitest env directive + existing@ts-expect-errorforreact-domonly. No new prose comments to flag.- Unchanged path-rewrite comments left intact.
Tests audit
fileActions.test.ts: success focus, failed create, navigation race — still good.Sidebar.test.tsx: Enter origin/commit for new-note / rename / new-html; new-note path now covers thehandsOffFocusside effect.renameMarkdownFilereturn value asserted.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Reviewed by a Warp Factory agent.
Rationale
Creating a Markdown note with Cmd+N opened the new document but left focus outside the editor, so there was no visible caret and typing had no effect. This began when Tiptap autofocus and the path-change focus effect were removed while adding file properties.
Restoring either behavior would also focus the editor during ordinary file navigation, stealing focus from the sidebar. Editor focus should follow creation intent instead of every path change.
Hubble has two Markdown creation flows:
HTML creation keeps its existing sidebar focus behavior because it does not open the Markdown editor.
Alternatives considered
I considered restoring Tiptap's autofocus option or the previous path-change focus effect. Both would fix new-note creation, but they would also move focus into the editor whenever a user opened a file from the sidebar.
I also considered focusing the editor as soon as the sidebar creates a note. That would interrupt the inline naming step.
A
continueEditingflag would express the desktop app's policy inside the shared sidebar. Instead, the sidebar reports the rename origin and how it was committed. The desktop app uses those facts to decide whether to focus the Markdown editor.Summary
Testing
pnpm checkpnpm check:react-compilerpnpm build:desktoppnpm --filter @hubble.md/ui testpnpm --filter @hubble.md/desktop test