Skip to content

Place the caret on a tap after the keyboard is hidden without Done on iOS - #87182

Open
ellatrix wants to merge 1 commit into
trunkfrom
fix/ios-retap-after-page-blur
Open

ellatrix wants to merge 1 commit into
trunkfrom
fix/ios-retap-after-page-blur

Conversation

@ellatrix

@ellatrix ellatrix commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What?

On iOS, tapping the selected paragraph after the keyboard was hidden without Done now places the caret at the tap. Before, the keyboard came back but the caret stayed where it was.

Reported by @dcalhoun while testing #86923: in Safari after tapping the address bar, and in GutenbergKit after every swipe down that hides the keyboard.

Why?

Hiding the keyboard without Done (a swipe down in GutenbergKit, or tapping Safari's address bar) only blurs the page: the canvas stays the focused element. The next tap focuses the page again before mousedown. useClickSelection cancels mousedown for a tap in the selected block when the canvas is focused, because iOS normally places the caret on the tap itself (#81042). But iOS does not place it on a tap into a page without focus, so cancelling mousedown left the caret where it was.

How?

useClickSelection checks whether the canvas is focused at pointerdown, before the tap focuses the page, instead of at mousedown.

The new iOS test hides the keyboard by dragging down into it, like GutenbergKit. The test app's web view now allows that (keyboardDismissMode = .interactive).

Testing Instructions

Open the demo post in Playground

  1. On an iPhone, open the link above in Safari.
  2. Tap the end of the second paragraph. The keyboard opens.
  3. Tap the address bar, then tap the page to close it.
  4. Tap the start of the same paragraph and type. The text goes where you tapped.

testTapAfterSwipingKeyboardAwayPlacesCaret fails 10 of 10 on trunk and passes 10 of 10 with this change, on iOS 27 and 26.5.

Testing Instructions for Keyboard

Unchanged: the change only affects a tap with a finger.

Screenshots or screencast

iOS 27 simulator, recorded while testTapAfterSwipingKeyboardAwayPlacesCaret runs: the test taps the end of the paragraph, drags the keyboard away, taps the start of the paragraph and types X. While the keyboard slides away, iOS draws the caret sliding down with it; the caret itself stays at the end, as the X in Before shows.

Before (trunk) After
The X lands at the end, where the caret was. The X lands at the tap.
retap-before-trunk.mp4
retap-after.mp4

Use of AI Tools

Investigated and written with Claude Code: reproduced in the iOS simulator, wrote the iOS test, and ran the iOS and end-to-end tests.

🤖 Generated with Claude Code

On iOS, hiding the keyboard without Done (a swipe down in GutenbergKit,
or Safari's address bar) only blurs the page: the canvas stays focused.
The next tap focuses the page again before mousedown, so the check for a
tap that iOS already placed the caret for passed, and cancelling the
mousedown left the caret where it was. Check focus at pointerdown, before
the tap focuses the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

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

📦 Bundle size

Size Change: +3 B (0%)

Total Size: 8.69 MB

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

b3f11d9 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric b7b6436 trunk % Change
timeToFirstByte 41.95 ms +13.83% -5.72% 40 ms +9.88% -8.13% 4.88%
largestContentfulPaint 70 ms +8.57% -8.57% 68 ms +2.94% -5.88% 2.94%
lcpMinusTtfb 24.65 ms +20.89% -2.84% 28.4 ms +3.7% -21.13% -13.2%
wpBeforeTemplate 21.72 ms +11.79% -6.54% 20.75 ms +13.25% -9.11% 4.67%
wpTemplate 16.27 ms +9.65% -5.96% 15.41 ms +8.76% -7.53% 5.58%
wpTotal 38.57 ms +12.47% -5.91% 36.59 ms +8.64% -8.5% 5.41%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric b7b6436 trunk % Change
timeToFirstByte 34.5 ms +4.78% -10.58% 31 ms +10.97% -2.1% 11.29%
largestContentfulPaint 64 ms +0% -6.25% 56 ms +17.86% -0% 14.29%
lcpMinusTtfb 28.55 ms +3.33% -6.13% 25.75 ms +21.94% -0.97% 10.87%
wpBeforeTemplate 18.12 ms +8.94% -6.84% 16.95 ms +12.45% -2.42% 6.9%
wpTemplate 12.28 ms +8.06% -11.24% 11.17 ms +5.37% -2.86% 9.94%
wpTotal 31.48 ms +5.05% -11.18% 28.15 ms +12.75% -2.38% 11.83%
wpMemoryUsage 6.44 MB +0% -0% 6.40 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric b7b6436 trunk % Change
mediaProcessingJpeg 234.74 ms +0.64% -1.6% 231.08 ms +0.7% -0.93% 1.58%
mediaProcessingAvif 3769.09 ms +0.74% -1.42% 3756.18 ms +0.68% -0.74% 0.34%
mediaProcessingJpegToAvif 2606.92 ms +0.79% -0.45% 2626.37 ms +0.2% -0.41% -0.74%

media-upload

Metric b7b6436 trunk % Change
jpegUploadProcessing 1479.21 ms +0.91% -1.43% 1447.48 ms +1.84% -1.07% 2.19%
pngUploadProcessing 210.56 ms +3.39% -1.5% 212.32 ms +4.42% -0.79% -0.83%
largeJpegUploadProcessing 1442.75 ms +0.66% -0.41% 1442.89 ms +0.71% -0.45% -0.01%
multipleImageUploadProcessing 1512.26 ms +0.22% -1.04% 1510.19 ms +0.3% -1% 0.14%

post-editor

Metric b7b6436 trunk % Change
serverResponse 343.03 ms +4.05% -16.66% 330.69 ms +1.67% -8.13% 3.73%
firstPaint 368.68 ms +9.17% -8.97% 349.92 ms +9.16% -10.53% 5.36%
domContentLoaded 701.63 ms +4.32% -5.73% 662.11 ms +0.71% -3.68% 5.97%
loaded 702.84 ms +4.31% -5.76% 663.3 ms +0.69% -3.7% 5.96%
firstContentfulPaint 405.3 ms +7.83% -7.92% 379.26 ms +0.72% -8.51% 6.87%
firstBlock 1876.67 ms +3.13% -3.39% 1790.63 ms +2.28% -1.58% 4.81%
type 16.65 ms +7.21% -4.5% 17.09 ms +8.25% -13.93% -2.57%
typeWithoutInspector 18.75 ms +22.51% -11.36% 17.43 ms +9.41% -11.99% 7.57%
typeWithTopToolbar 24.66 ms +3.12% -17.36% 20.19 ms +15.55% -9.66% 22.14%
typeContainer 8 ms +32.62% -11.38% 8.85 ms +37.74% -11.3% -9.6%
focus 105.93 ms +3.36% -6.78% 98.2 ms +11.87% -10.91% 7.87%
firstFocus 239.82 ms +0% -0% 185.47 ms +0% -0% 29.3%
selectAll 292.21 ms +4.24% -0.91% 280.95 ms +14.42% -1.38% 4.01%
undo 29.63 ms +19.1% -3.85% 30.34 ms +25.61% -6.89% -2.34%
listViewOpen 60.21 ms +21.71% -1.88% 63.64 ms +16.67% -13.12% -5.39%
inserterOpen 37.53 ms +55.48% -20.97% 40.08 ms +6.81% -19.51% -6.36%
inserterHover 11.77 ms +41.97% -9.09% 11.94 ms +13.4% -9.21% -1.42%
inserterSearch 8.42 ms +35.87% -7.48% 8.99 ms +45.72% -12.9% -6.34%
loadPatterns 555.24 ms +2.47% -10.69% 558.04 ms +3% -12.18% -0.5%
wpTotal 333.86 ms +3.81% -17.76% 321.74 ms +1.76% -9.05% 3.77%
wpMemoryUsage 14.81 MB +0% -0% 14.77 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric b7b6436 trunk % Change
serverResponse 406.88 ms +0.85% -5.48% 399.96 ms +2.74% -5.8% 1.73%
firstPaint 442.15 ms +8.77% -8.01% 444.41 ms +6.9% -10.86% -0.51%
domContentLoaded 845.28 ms +4.91% -0.37% 838.49 ms +2.47% -0.92% 0.81%
loaded 846.27 ms +4.92% -0.37% 839.42 ms +2.47% -0.89% 0.82%
firstContentfulPaint 478.26 ms +9.5% -4.27% 474.85 ms +2.39% -2.68% 0.72%
firstBlock 2472.08 ms +0.77% -1.51% 2447.88 ms +0.65% -0.29% 0.99%
type 18.15 ms +12.18% -5.45% 18.02 ms +10.1% -10.93% 0.72%
navigate 113.85 ms +0.69% -0.61% 114.77 ms +3.15% -2.03% -0.8%
loadPatterns 1358.28 ms +19.46% -5.67% 1394.59 ms +4.57% -5.38% -2.6%
loadPages 926.79 ms +0.71% -0.56% 943.89 ms +3.42% -1.27% -1.81%
wpTotal 397.13 ms +0.9% -5.63% 390 ms +2.87% -5.92% 1.83%
wpMemoryUsage 12.83 MB +0% -0% 12.80 MB +0% -0% 0.25%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

b3f11d9 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.

As a user I want to be able to create a navigation overlay for a specific navigation block in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: /(Editor publish|Save panel)/ }).getByRole('button', { name: 'Save', exact: true })

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:48:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:91:4
Navigates the items list via UP/DOWN arrow keys (Site Editor v2) in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByLabel('Page One')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByLabel('Page One') with timeout 5000ms
  - waiting for getByLabel('Page One')
    14 × locator resolved to <button type="button" aria-pressed="true" data-active-item="true" id="view-list-0-13-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-13-label" aria-describedby="view-list-0-13-description"></button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:149:49
a navigation superseded by the traversal discharges to idle in /test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts, passed after 1 failed attempt.
SyntaxError: Unexpected token 'o', "not hydrated" is not valid JSON
    at readLog (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts:28:14)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts:47:24
    at waitForLogLength (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts:46:2)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts:693:5
should select synced pattern in /test/e2e/specs/editor/various/writing-flow.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]') with timeout 5000ms
  - waiting for locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
    14 × locator resolved to <div tabindex="0" role="document" draggable="true" data-title="Pattern" data-type="core/block" data-is-drop-zone="true" aria-label="Block: Pattern" id="block-dda47696-2b5e-46fa-8f8c-a027f66d521f" data-block="dda47696-2b5e-46fa-8f8c-a027f66d521f" class="block-editor-block-list__block wp-block is-selected is-reusable block-library-block__reusable-block-container wp-block-block block-editor-block-list__layout">…</div>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/writing-flow.spec.js:1464:5

b3f11d9 Run

@ellatrix ellatrix added the [Type] Bug An existing feature does not function as intended label Nov 20, 2026
@ellatrix
ellatrix marked this pull request as ready for review November 21, 2026 02:45
@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 Nov 21, 2026

This branch has not been deployed

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

Labels

Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant