Skip to content

Writing flow: keep the scroll position when a selection becomes a block multi-selection - #80609

Closed
ellatrix wants to merge 1 commit into
trunkfrom
fix/multi-select-scroll-jump
Closed

ellatrix wants to merge 1 commit into
trunkfrom
fix/multi-select-scroll-jump

Conversation

@ellatrix

Copy link
Copy Markdown
Member

What?

Selecting blocks across a scrolled page (e.g. shift+clicking a block far down while a block at the top is selected) no longer scrolls the viewport to the top of the document and back. See #72512.

Why?

When a selection becomes a block multi-selection, the block list wrapper becomes the editing host and receives focus, either from the explicit focus call or from the browser moving focus there on its own. Focusing the wrapper scrolls it into view, and since it spans the whole document, that means jumping to the top.

How?

The focus call passes preventScroll: true. Focus still moves; only the scrolling is suppressed. There is no case where scrolling to the top of the wrapper is wanted: anything that legitimately scrolls (caret placement, block focus) does so through its own element.

The new test records scroll events during the gesture, since asserting the position afterwards would miss the round trip. It is skipped on WebKit: transient single selections during the gesture separately trigger the selected block scroll-into-view behavior there, part of the selection races tracked in #80608.

Testing Instructions

  1. Insert a spacer followed by enough paragraphs to make the page scroll.
  2. Click the spacer to select it, then scroll to the bottom.
  3. Shift+click a paragraph near the bottom.
  4. The viewport should not move. On trunk it snaps to the top of the document and animates back down.

Use of AI Tools

Written with Claude Code, reviewed and tested by me.

@github-actions github-actions Bot added [Package] Rich text /packages/rich-text [Package] Block editor /packages/block-editor labels Jul 23, 2026
Focusing the editable wrapper, or the browser moving focus to it on its
own when it becomes the editing host, scrolls the viewport to the top
of the wrapper. Making a block multi-selection across a scrolled page
snapped the viewport to the top of the document and back.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
@ellatrix
ellatrix force-pushed the fix/multi-select-scroll-jump branch from 6839b22 to c3017d1 Compare July 23, 2026 05:17
@github-actions github-actions Bot removed the [Package] Rich text /packages/rich-text label Jul 23, 2026
@github-actions

Copy link
Copy Markdown

Size Change: +7 B (0%)

Total Size: 7.75 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 428 kB +7 B (0%)

compressed-size-action

@ellatrix

Copy link
Copy Markdown
Member Author

Superseded by #80651, which includes both the preventScroll fix and the scroll regression test.

@ellatrix ellatrix closed this Jul 24, 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.

1 participant