Repository navigation
Revert "fix(markdown): return focus to editor from find bar" (#23175) - #24500
Conversation
This reverts commit d9d5993.
|
| onMouseDown={(event) => { | ||
| if (shouldReturnFocusToEditor(event)) { | ||
| // Keep the find bar open while handing keyboard focus back to the document. | ||
| searchState.searchInputRef.current?.blur() | ||
| editor?.commands.focus() | ||
| } | ||
| if (!shouldFocusEmptyEditorFromSurfaceClick(event, editor)) { |
There was a problem hiding this comment.
Click regression lacks a test The existing scroll-restoration test checks the viewport after a tab switch but never clicks the document. A test that switches from code view, scrolls down, then clicks or drags in the rich editor could check both the viewport and caret position. Without it, a future focus change could bring back the jump to the top without being caught.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Revert of #23175 in
RichMarkdownEditorSurface.tsx— deletes theshouldReturnFocusToEditorhelper and theonMouseDownbranch that blurred the find input and callededitor.commands.focus()on any left-click in.ProseMirror, restoring pre-#23175 click behavior.
The deletion is an exact inverse of the #23175 merge commit d9d5993 (same file, +13/-0), and no test referenced the removed helper, so the revert is complete and leaves no dead code (searchState.searchInputRef is still consumed by RichMarkdownSearchBar). The handler left behind (shouldFocusEmptyEditorFromSurfaceClick) is pre-existing and unchanged.
One process note: #22693 was closed by #23175, so reverting returns that bug (rich Markdown while the find bar is open) while the issue stays closed. Since the PR already frames the real fix as a separate change, it is worth reopening or re-linking #22693 so the regression is not lost. Not blocking — the trade-off is explicit and the analysis is sound.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe rich Markdown editor no longer blurs the search input and returns focus to the editor when a left-click occurs inside Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Normal clicks can return focus to the editor without the removed focus command that caused the reported scroll jump. No merge-blocking issue is established. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |

ELI5
In the rich Markdown editor, clicking somewhere in the document could throw you back to the top of the file. This undoes the recent change that caused it.
What Changed
Reverts #23175.
Mechanism: #23175 added a mousedown handler on the rich editor's scroll area. On every left-click inside the document it called Tiptap's
editor.commands.focus(). If the editor isn't focused yet (for example, right after switching from code view, when focus is still on the view toggle), that call:scrollIntoView()on the next animation frame. That frame fires before ProseMirror handles the mouseup, which is when the click actually moves the caret.So the view scrolls to the old caret at the top of the document. Removing the handler lets the browser and ProseMirror focus the editor and place the caret themselves.
Why
#23175 was a narrow workaround for #22693 (with the find bar open, keystrokes went to the find bar instead of the document). It caused a worse regression: the editor jumps to the top whenever you click in a document that isn't focused. Reverting is the smallest safe change.
Trade-off: #22693 may come back in rich Markdown mode while the find bar is open. That issue also reports the same focus problem in
.ts/.jsonfiles, which use the code editor and were never covered by #23175, so the real fix for #22693 is to find what pulls focus back to the find bar. That will be a separate change.Underlying problem, for a follow-up: after a code → editor switch, the rich editor's selection is left at the start of the document while scroll is restored to the middle. Any
focus()/scrollIntoView()call without a position will jump to the top. Carrying the cursor across mode switches (and keeping cursor and scroll together) would fix that whole class of bugs; it's related to #14800 / #14940.Linked Issue
Fixes #23596
Visual Proof
Pending. A before/after recording will be added.
Testing
pnpm tc:webpasses; oxlint is clean on the changed file.Not yet manually verified in the running app.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
No tests added: this is a pure revert of a 13-line handler that had no tests.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Renderer-only change that removes code. No impact on SSH/remote, mobile, or cross-platform paths beyond the possible return of #22693 described above.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)