Skip to content

fix: Firefox pressing up arrow takes two lines up#71205

Open
DarkMatter-999 wants to merge 2 commits intoWordPress:trunkfrom
DarkMatter-999:try/firefox-fix-cursor-nav
Open

fix: Firefox pressing up arrow takes two lines up#71205
DarkMatter-999 wants to merge 2 commits intoWordPress:trunkfrom
DarkMatter-999:try/firefox-fix-cursor-nav

Conversation

@DarkMatter-999
Copy link
Copy Markdown

What?

Closes #34215

This PR fixes an issue where pressing the Up arrow key from the start of the second line in a multi-line paragraph would jump the cursor two lines up instead of one. This behavior was observed in Firefox.

Why?

The current behavior breaks expected navigation and writing flow. When the cursor is at the beginning of the second line in a block (like a paragraph), the user expects it to move to the first line of that same block. Instead, the editor either jumps over the first line or selects the block above.

How?

The PR adjusts the key handling logic to better detect the current cursor position within the block’s text content.

Testing Instructions

  1. Open a post or page in the editor.
  2. Add any block (eg. a paragraph block).
  3. Insert a paragraph block directly below it.
  4. Write a paragraph (just typing a long enough to make it wrap around multiple lines).
  5. Place the cursor at the start of the second line of the paragraph block.
  6. Press the Up arrow key.

Testing Instructions for Keyboard

  1. Open a post or page in the editor.
  2. Add any block (eg. a paragraph block).
  3. Insert a paragraph block directly below it.
  4. Type a long paragraph to ensure it wraps to multiple lines.
  5. Use arrow keys to navigate within and between lines.
  6. Press Up arrow when at the beginning of the second line.

Expected result:

  • The cursor should move one line up to the first line of the same paragraph block.
  • It should not skip to the block above or highlight another block.

Screenshots or screencast

Expected Behavior: Chrome

chrome.mov

Before: Firefox

firefox-before.mov

After: Firefox

firefox-after.mov

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 14, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @nyanpasu64.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: nyanpasu64.

Co-authored-by: DarkMatter-999 <lakshyajeet@git.wordpress.org>
Co-authored-by: USERSATOSHI <tusharbharti@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: westnz <west7@git.wordpress.org>
Co-authored-by: skorasaurus <skorasaurus@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 14, 2025

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin, New Block.
  • Labels found: Browser Issues, [Package] DOM, First-time Contributor.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @DarkMatter-999! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Aug 14, 2025
@DarkMatter-999 DarkMatter-999 marked this pull request as draft August 14, 2025 08:34
@t-hamano t-hamano added Browser Issues Issues or PRs that are related to browser specific problems [Package] DOM /packages/dom labels Aug 14, 2025
@DarkMatter-999 DarkMatter-999 marked this pull request as ready for review August 14, 2025 10:07
@USERSATOSHI
Copy link
Copy Markdown
Contributor

I think this is only partially fixed.

Arrow UP case is fixed
Arrow DOWN case still occurring.

Screen.Recording.2025-08-14.at.10.36.17.PM.mov

@Mamaduka
Copy link
Copy Markdown
Member

Mamaduka commented Apr 1, 2026

Created an alternative fix (#76954), which handles both cases and uses a different method that doesn't depend on browser check.

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

Labels

Browser Issues Issues or PRs that are related to browser specific problems First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] DOM /packages/dom

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firefox: Pressing Up arrow takes you two lines up, if cursor is at beginning of second line of paragraph

4 participants