fix(web): handle macOS Home and End in composer#2508
fix(web): handle macOS Home and End in composer#2508GuilhermeVieiraDev wants to merge 1 commit intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
ApprovabilityVerdict: Approved This is a simple, self-contained bug fix that adds macOS Home/End key support to the composer. The change is isolated to a new Lexical plugin, uses standard browser Selection APIs, and follows existing patterns in the codebase. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Fixed the composer Home/End key behavior on macOS external keyboards.
The composer now handles plain Home/End inside the Lexical editor on macOS by asking the browser to move the DOM selection to the visual line boundary, then syncing that selection back into Lexical. Modifier variants like Cmd/Ctrl/Option + Home/End are left alone, and non-macOS platforms keep their native behavior.
Why
On Linux, Home/End already move to the start/end of the current visual line in the composer. On macOS with external keyboards, the same keys were not moving the caret inside the contenteditable editor.
UI Changes
Screen.Recording.2026-05-05.at.00.13.05.mov
Checklist
Note
Low Risk
Low risk, localized to composer key handling on macOS; main risk is minor caret/selection edge cases from syncing DOM selection back into Lexical.
Overview
Fixes Home/End behavior in the composer on macOS (notably external keyboards) by adding a Lexical plugin that intercepts plain
Home/Endkeydown events.The plugin uses the browser selection (
selection.modify(..., "lineboundary")) to move/extend to the visual line boundary, then syncs the updated DOM selection back into Lexical via$createRangeSelectionFromDom; modifier variants and non-macOS platforms are left to native behavior.Reviewed by Cursor Bugbot for commit 8f53d3b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix Home and End key behavior in the composer on macOS
Adds a
ComposerHomeEndKeyPluginin ComposerPromptEditor.tsx that interceptsHome/Endkey presses on macOS. It usesSelection.modifyto move or extend the DOM selection to the line boundary, then syncs the result back to the Lexical editor state via$createRangeSelectionFromDom. Without this, the browser default moves the cursor to the document start/end instead of the line boundary.Macroscope summarized 8f53d3b.