Skip to content

List View: Place caret at end of block when selecting#76776

Closed
scruffian wants to merge 1 commit intoWordPress:trunkfrom
scruffian:issue-76774
Closed

List View: Place caret at end of block when selecting#76776
scruffian wants to merge 1 commit intoWordPress:trunkfrom
scruffian:issue-76774

Conversation

@scruffian
Copy link
Copy Markdown
Contributor

What?

Closes #76774

Places the caret at the end of a block (instead of the start) when selecting a block from the List View panel.

Why?

When selecting a block via List View, the caret was placed at the start of the block. This meant pressing Enter would create a new block before the selected block, which is unexpected. Users expect a new block to be created after the selected block.

How?

Passes -1 as the focusPosition parameter when selecting a block from the List View (block.js). The value -1 tells useFocusFirstElement to place the caret at the end of the last text input in the block, rather than the start of the first.

Testing Instructions

  1. Open a post or page.
  2. Insert two Paragraph blocks with some text content.
  3. Open the List View panel (Alt+Shift+O / Ctrl+Shift+O).
  4. Click the first Paragraph in List View to select it.
  5. Observe the caret is at the end of the block text in the canvas.
  6. Press Enter.
  7. Verify a new empty block is created after the first paragraph (not before it).

Testing Instructions for Keyboard

  1. Open a post or page and insert two Paragraph blocks with text.
  2. Open the List View panel using Alt+Shift+O (Windows) or Ctrl+Shift+O (Mac).
  3. Use arrow keys to navigate to the first Paragraph block in the List View.
  4. Press Enter or Space to select the block.
  5. The canvas should now be focused with the caret at the end of the block text.
  6. Press Enter to create a new block.
  7. Verify the new block appears after the selected block.

Use of AI Tools

This PR was authored with the assistance of Claude Code (Claude Opus 4.6).

When selecting a block from the List View, the caret is now placed at the
end of the block instead of the start. This ensures that pressing Enter
after selecting a block creates a new block after the selected block,
matching user expectations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@scruffian scruffian requested a review from ellatrix as a code owner March 24, 2026 06:59
@github-actions
Copy link
Copy Markdown

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.

  • Required label: Any label starting with [Type].
  • Labels found: .

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 github-actions bot added the [Package] Block editor /packages/block-editor label Mar 24, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

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.

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

Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>

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

Copy link
Copy Markdown
Member

@Mayank-Tripathi32 Mayank-Tripathi32 left a comment

Choose a reason for hiding this comment

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

Works great for me.

Test.Caret.mov

@scruffian
Copy link
Copy Markdown
Contributor Author

Closing in favour of #76797

@scruffian scruffian closed this Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List View Block Selection: Add caret at the end of the block

2 participants