Skip to content

Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen - #85408

Merged
ellatrix merged 6 commits into
trunkfrom
fix/arrow-down-off-screen-edge
Oct 23, 2026
Merged

ellatrix merged 6 commits into
trunkfrom
fix/arrow-down-off-screen-edge

Conversation

@ellatrix

@ellatrix ellatrix commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

What?

Fixes #82839. Alternative to #84800. Follow up to #80708.

Arrow Up and Down no longer stop at a block whose padding is just outside the viewport.

Why?

isEdge hit-tests a point at the block's edge. A point outside the viewport can't be hit-tested, so #80708 assumed the caret is not on the edge line whenever that point is off-screen. That's wrong when only the padding beyond the edge line is off-screen.

How?

  1. Lines are measured with a range
    • If any line of the block lies below the caret (above, going up), it's not at the vertical edge.
    • Otherwise it is. A range measures lines outside the viewport, so no hit-test or scrolling is needed.
  2. The horizontal check hit-tests the caret's line

Testing Instructions

  1. Add 20 preformatted blocks.
  2. Scroll so one block's text is just above the bottom of the screen and its padding is below.
  3. Put the caret in it and press Arrow Down: the caret moves to the next block.

Use of AI Tools

Written with the help of Claude Code.

ellatrix and others added 2 commits October 22, 2026 11:23
Arrow Down stopped at a block whose bottom edge was a few pixels below
the viewport: the edge test point was off-screen, so the caret was
assumed to be away from the last line. Lines are now measured with a
range, which works off-screen, and the hit-test uses the selection's
line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the [Package] DOM /packages/dom label Oct 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

Unlinked Accounts

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

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

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>
Co-authored-by: robelsust <therssoftware@git.wordpress.org>

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

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: -5 B (0%)

Total Size: 9.06 MB

📦 View Changed
Filename Size Change
build/scripts/dom/index.min.js 5.33 kB -5 B (-0.09%)

17eb24a Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric ae90adf trunk % Change
timeToFirstByte 41.6 ms +5.05% -3.13% 43.95 ms +9.56% -8.65% -5.35%
largestContentfulPaint 76 ms +2.63% -7.89% 76 ms +7.89% -10.53% 0%
lcpMinusTtfb 32.35 ms +10.36% -14.53% 28.2 ms +27.84% -2.48% 14.72%
wpBeforeTemplate 21.76 ms +9.7% -0.69% 21.91 ms +23.28% -1.96% -0.68%
wpTemplate 16.33 ms +4.23% -5.08% 16.2 ms +4.01% -4.63% 0.8%
wpTotal 38.52 ms +4.21% -3.45% 39.31 ms +12.26% -5.8% -2.01%
wpMemoryUsage 7.67 MB +0% -0% 7.64 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric ae90adf trunk % Change
timeToFirstByte 34.85 ms +7.6% -1.72% 34.4 ms +6.25% -1.45% 1.31%
largestContentfulPaint 80 ms +0% -2.5% 76 ms +5.26% -0% 5.26%
lcpMinusTtfb 44.4 ms +2.48% -5.29% 42.1 ms +0.71% -0.95% 5.46%
wpBeforeTemplate 19.35 ms +9.3% -0.78% 19.25 ms +1.77% -1.45% 0.52%
wpTemplate 12.49 ms +2.56% -2.16% 12.49 ms +3.28% -1.92% 0%
wpTotal 31.92 ms +8.96% -1.1% 31.83 ms +6.47% -1.79% 0.28%
wpMemoryUsage 6.36 MB +0% -0% 6.33 MB +0% -0% 0.54%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric ae90adf trunk % Change
mediaProcessingJpeg 321.46 ms +5.05% -1.76% 323.31 ms +1.62% -0.77% -0.57%
mediaProcessingAvif 4828.99 ms +0.48% -0.42% 4829.99 ms +0.53% -0.11% -0.02%
mediaProcessingJpegToAvif 3364.6 ms +0.46% -0.55% 3367.93 ms +0.53% -0.07% -0.1%

media-upload

Metric ae90adf trunk % Change
jpegUploadProcessing 1405.79 ms +2.53% -0.45% 1387.34 ms +1.78% -0.17% 1.33%
pngUploadProcessing 202.13 ms +20.25% -9.99% 186.92 ms +11.17% -2.68% 8.14%
largeJpegUploadProcessing 1400.49 ms +1.15% -1.29% 1406.33 ms +0.83% -1.38% -0.42%
multipleImageUploadProcessing 1483.78 ms +1.46% -0.49% 1462.38 ms +1.38% -0.46% 1.46%

post-editor

Metric ae90adf trunk % Change
serverResponse 501.07 ms +11.61% -2.45% 531.86 ms +6.17% -5.3% -5.79%
firstPaint 381.23 ms +27.86% -23.27% 489.41 ms +9.21% -42.07% -22.1%
domContentLoaded 1236.48 ms +2.11% -1.94% 1226.91 ms +3.31% -0.64% 0.78%
loaded 1237.76 ms +2.12% -1.96% 1228.39 ms +3.29% -0.65% 0.76%
firstContentfulPaint 488.89 ms +10.94% -5.42% 524.4 ms +2.4% -11.9% -6.77%
firstBlock 3702.94 ms +0.95% -2.08% 3715.98 ms +2.91% -2.1% -0.35%
type 19.29 ms +3.73% -3.89% 19.06 ms +6.03% -5.56% 1.21%
typeWithoutInspector 18.75 ms +7.2% -3.47% 20.44 ms +5.87% -4.21% -8.27%
typeWithTopToolbar 26.13 ms +1.3% -3.67% 26.57 ms +9.75% -2.75% -1.66%
typeContainer 8.77 ms +13.68% -3.99% 9.11 ms +5.6% -1.87% -3.73%
focus 130.77 ms +3.11% -4.53% 124.55 ms +1.49% -4.09% 4.99%
firstFocus 267.6 ms +0% -0% 248.96 ms +0% -0% 7.49%
selectAll 610.68 ms +1.7% -2.36% 558.42 ms +4.04% -0.24% 9.36%
listViewOpen 86.84 ms +14.26% -7.51% 88.38 ms +9.1% -9.86% -1.74%
inserterOpen 42.05 ms +14.74% -5.78% 41.88 ms +3.61% -12.51% 0.41%
inserterHover 11.63 ms +11.09% -5.5% 11.94 ms +6.53% -6.78% -2.6%
inserterSearch 8.2 ms +9.39% -5.12% 8.39 ms +3.81% -9.54% -2.26%
loadPatterns 709.82 ms +7.99% -3.89% 630.44 ms +7.52% -1.53% 12.59%
wpTotal 491.48 ms +11.77% -2.58% 522.05 ms +6.33% -5.36% -5.86%
wpMemoryUsage 14.71 MB +0% -0% 14.67 MB +0% -0% 0.24%
wpDbQueries 54.5 +0.92% -0.92% 55 +0% -1.82% -0.91%

site-editor

Metric ae90adf trunk % Change
serverResponse 410.89 ms +4.2% -5.59% 401.39 ms +5.02% -6.06% 2.37%
firstPaint 270.27 ms +10.33% -20.02% 264.27 ms +18.52% -29.5% 2.27%
domContentLoaded 1158.66 ms +0.91% -1.15% 1151.31 ms +1.47% -0.84% 0.64%
loaded 1159.72 ms +0.9% -1.17% 1152.36 ms +1.45% -0.85% 0.64%
firstContentfulPaint 488.9 ms +4.91% -4.12% 466.47 ms +6.09% -26.06% 4.81%
firstBlock 4172.82 ms +1.27% -2.01% 4187.56 ms +0.47% -1.21% -0.35%
type 18.78 ms +2.13% -2.61% 18.71 ms +3.47% -1.07% 0.37%
navigate 124.3 ms +7.29% -8.47% 116.25 ms +8.66% -7.39% 6.92%
loadPatterns 1226.15 ms +14.95% -4.12% 1300.61 ms +2.76% -3.71% -5.73%
loadPages 992.57 ms +0.38% -1.1% 992.23 ms +4.74% -1.57% 0.03%
wpTotal 401.43 ms +4.27% -5.82% 392.14 ms +4.98% -6.25% 2.37%
wpMemoryUsage 12.72 MB +0% -0% 12.69 MB +0% -0% 0.28%
wpDbQueries 44 +2.27% -0% 44 +2.27% -0% 0%

17eb24a Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Regression: updating a specific option will only change its value and will not corrupt others in /test/e2e/specs/editor/various/core-settings.spec.js, passed after 1 failed attempt.
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Array [
    "rewrite_rules",
-   "SERIALIZED DATA",
+   "",
  ]
    at forEach (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:46:26)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:43:35

17eb24a Run

It has the same flaw when only the padding is off-screen, and a block
wider than the viewport is rare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ellatrix ellatrix added the [Type] Regression Related to a regression in the latest release label Oct 22, 2026
@ellatrix
ellatrix marked this pull request as ready for review October 22, 2026 18:28
ellatrix and others added 3 commits October 22, 2026 19:20
Once no line lies beyond the selection, it is on the edge line, so the
vertical check needs no hit-test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test point is on the selection's line, which is within the viewport
when the selection is. When it can't be measured, the browser handles
the key instead of the page scrolling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ellatrix ellatrix added the Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 23, 2026
@ellatrix ellatrix changed the title Writing flow: Move to the next block when only its padding is off-screen Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen Oct 23, 2026
@ellatrix
ellatrix merged commit f152716 into trunk Oct 23, 2026
93 of 94 checks passed
@ellatrix
ellatrix deleted the fix/arrow-down-off-screen-edge branch October 23, 2026 04:52
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 23, 2026
@github-actions

Copy link
Copy Markdown

There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch.

PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk.

# Checkout the wp/7.2 branch instead of trunk.
git checkout wp/7.2

# Create a new branch for your PR.
git checkout -b my-branch

# Cherry-pick the commit.
git cherry-pick f152716d58fec93999b51f3aae9960b725cfd1c5

# Check which files have conflicts.
git status

# Resolve the conflict...
# Add the resolved files to the staging area.
git status
git add .
git cherry-pick --continue

# Push the branch to the repository
git push origin my-branch

# Create a PR and set the base to the wp/7.2 branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.

@t-hamano

Copy link
Copy Markdown
Contributor

@ellatrix If this PR is needed for WordPress 7.2, can you manually create a backport PR?

Mamaduka added a commit that referenced this pull request Nov 3, 2026
…screen (#85408)

Unlinked contributors: kurikimuchi.

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>
Co-authored-by: robelsust <therssoftware@git.wordpress.org>
@Mamaduka Mamaduka added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Nov 3, 2026
wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Nov 3, 2026
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch).

A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a

- Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848)
- Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530)
- Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892)
- Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565)
- Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455)
- Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935)
- Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060)
- Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883)
- [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032)
- Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050)
- [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060)
- Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059)
- [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062)
- Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158)
- UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183)
- Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959)
- Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168)
- Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415)
- Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408)
- Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420)
- Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795)
- Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777)
- Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873)

Props mamaduka.
See #66340.

git-svn-id: https://develop.svn.wordpress.org/trunk@65225 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 3, 2026
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch).

A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a

- Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848)
- Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530)
- Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892)
- Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565)
- Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455)
- Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935)
- Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060)
- Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883)
- [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032)
- Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050)
- [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060)
- Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059)
- [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062)
- Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158)
- UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183)
- Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959)
- Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168)
- Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415)
- Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408)
- Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420)
- Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795)
- Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777)
- Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873)

Props mamaduka.
See #66340.
Built from https://develop.svn.wordpress.org/trunk@65225


git-svn-id: http://core.svn.wordpress.org/trunk@64374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
arshidkv12 pushed a commit to arshidkv12/wordpress-develop that referenced this pull request Nov 21, 2026
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch).

A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a

- Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848)
- Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530)
- Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892)
- Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565)
- Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455)
- Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935)
- Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060)
- Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883)
- [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032)
- Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050)
- [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060)
- Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059)
- [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062)
- Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158)
- UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183)
- Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959)
- Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168)
- Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415)
- Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408)
- Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420)
- Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795)
- Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777)
- Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873)

Props mamaduka.
See #66340.

git-svn-id: https://develop.svn.wordpress.org/trunk@65225 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Package] DOM /packages/dom [Type] Regression Related to a regression in the latest release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Writing Flow regression in 7.1] Down arrow key navigation fails to auto-scroll viewport when post title is visible

3 participants