Skip to content

fix(web): handle macOS Home and End in composer#2508

Open
GuilhermeVieiraDev wants to merge 1 commit intopingdotgg:mainfrom
GuilhermeVieiraDev:fix/macos-home-end-composer
Open

fix(web): handle macOS Home and End in composer#2508
GuilhermeVieiraDev wants to merge 1 commit intopingdotgg:mainfrom
GuilhermeVieiraDev:fix/macos-home-end-composer

Conversation

@GuilhermeVieiraDev
Copy link
Copy Markdown
Contributor

@GuilhermeVieiraDev GuilhermeVieiraDev commented May 4, 2026

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

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

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/End keydown 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 ComposerHomeEndKeyPlugin in ComposerPromptEditor.tsx that intercepts Home/End key presses on macOS. It uses Selection.modify to 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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f62ac292-d6d5-4892-80eb-d9890dfcc6e9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels May 4, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 4, 2026

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant