Skip to content

[lexical] Bug Fix: Ctrl+ArrowLeft/Right no longer jumps to line start/end - #9068

Closed
sahiee-dev wants to merge 1 commit into
meta:mainfrom
sahiee-dev:fix/ctrl-arrow-word-navigation
Closed

sahiee-dev wants to merge 1 commit into
meta:mainfrom
sahiee-dev:fix/ctrl-arrow-word-navigation

Conversation

@sahiee-dev

Copy link
Copy Markdown
Contributor

Description

isMoveToStart()/isMoveToEnd() treated Ctrl on Windows/Linux as equivalent to Cmd on Mac, the same way letter shortcuts like Bold treat them.

However, jumping to the start/end of a line with an arrow key is a macOS only gesture. Windows/Linux use the Home/End keys for this and reserve Ctrl+Arrow for word-by-word navigation.

As a result, plain Ctrl+ArrowLeft/Right on Windows/Linux was being hijacked into a jump to the start/end of the block instead of moving one word at a time.

This was most noticeable in blocks starting with an inline decorator, such as a Date chip, where Lexical already intercepts the key to work around a separate Chromium caret bug. That interception was firing unconditionally regardless of where the caret actually was in the block.

I dug deep and found that, This ctrlKey/metaKey mixup goes back to the original 2022 implementation (#2257) and was later carried into a shared, platform aware constant by #7443 without accounting for the differences in arrow key behavior between platforms. This likely went unnoticed until #8558 widened the handler from code blocks to general rich text.

This PR scopes isMoveToStart()/isMoveToEnd() to only match on metaKey (Cmd). This leaves Ctrl+Arrow on Windows/Linux alone so it can fall through to native word navigation, while Cmd+Arrow on macOS keeps its existing behavior unchanged.

Closes #8958

Test plan

Before

  1. In the playground, insert a Date (or any inline decorator) at the start of a paragraph.
  2. Type some text after it, for example, "the quick brown fox jumps".
  3. Place the cursor in the middle/end of the text.
  4. Press Ctrl+ArrowLeft on Windows/Linux.

The cursor jumps all the way to the start of the paragraph instead of moving back one word.

After

Follow the same steps. Ctrl+ArrowLeft now moves the cursor back one word at a time, as expected.

Verified manually on Windows.

Cmd+ArrowLeft/Right on macOS is unaffected and still jumps to the block start/end past the decorator, as covered by the existing #8555/#8601/#8604 tests.

Added packages/lexical/src/__tests__/unit/LexicalUtils.test.ts with isMoveToEnd() / isMoveToStart() reject plain Ctrl+Arrow (#8958). The test asserts that Ctrl+ArrowLeft/Right no longer match, while Cmd+ArrowLeft/Right still do.

…/end (meta#8958)

isMoveToStart()/isMoveToEnd() treated Ctrl on Windows/Linux as equivalent
to Cmd on Mac, same as letter shortcuts like Bold. But arrow-key line
jumps are a macOS-only gesture (Windows/Linux use Home/End instead and
reserve Ctrl+Arrow for word navigation), so plain Ctrl+ArrowLeft was
being hijacked into a jump to the start of the block instead of moving
back one word - most noticeable in blocks starting with an inline
decorator, where Lexical intercepts the key to work around a Chromium
caret bug.
@vercel

vercel Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 13, 2026 7:06pm
lexical-playground Ready Ready Preview Aug 13, 2026 7:06pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 13, 2026

@etrepum etrepum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metaKey only means that the windows key would perform this action, it sounds like a mac-only shortcut would be preferred here. Either way I think it would be best to wait for #8876 to land before making any changes to built-in shortcuts.

@sahiee-dev

Copy link
Copy Markdown
Contributor Author

Good catch on metaKey, Windows key would technically match there, that's a fair point.
I've got a fix (explicit IS_APPLE gate) but I'll hold off pushing until #8876 lands, then rebase onto the new shortcut table. Thanks for flagging.

This branch was successfully deployed

2 active deployments
Preview – lexical — d1907e24 Deployed Aug 13, 2026 by vercel[bot]
Preview – lexical-playground — d1907e24 Deployed Aug 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Ctrl + Left moves cursor to row start not to previous word if row starts with decorator (e.g. Date)

2 participants