Skip to content

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

Merged
ellatrix merged 2 commits into
trunkfrom
fix/ios-retap-after-page-blur
Nov 24, 2026
Merged

ellatrix merged 2 commits 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: +8 B (0%)

Total Size: 8.71 MB

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

92368d2 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 627e42d trunk % Change
timeToFirstByte 35.75 ms +9.09% -2.24% 34.95 ms +11.73% -4.86% 2.29%
largestContentfulPaint 60 ms +6.67% -6.67% 60 ms +6.67% -3.33% 0%
lcpMinusTtfb 22.65 ms +13.02% -7.06% 25.05 ms +9.58% -16.77% -9.58%
wpBeforeTemplate 18.79 ms +4.95% -2.24% 18.29 ms +9.4% -4.48% 2.73%
wpTemplate 13.92 ms +5.1% -2.3% 13.58 ms +8.32% -3.98% 2.5%
wpTotal 32.76 ms +9.04% -2.72% 31.86 ms +12.24% -5.18% 2.82%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.46%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 627e42d trunk % Change
timeToFirstByte 29.85 ms +7.37% -2.01% 28.65 ms +14.49% -1.75% 4.19%
largestContentfulPaint 56 ms +0% -7.14% 54 ms +7.41% -3.7% 3.7%
lcpMinusTtfb 25.35 ms +3.55% -6.9% 23.9 ms +9.41% -2.09% 6.07%
wpBeforeTemplate 16.29 ms +3.31% -0.8% 16.12 ms +9.74% -1.05% 1.05%
wpTemplate 10.49 ms +6.2% -4.86% 10.24 ms +7.71% -4.69% 2.44%
wpTotal 27.1 ms +5.46% -2.03% 26.2 ms +14.31% -1.79% 3.44%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 627e42d trunk % Change
mediaProcessingJpeg 224.31 ms +0.74% -0.59% 227.38 ms +1.37% -2.34% -1.35%
mediaProcessingAvif 3647.48 ms +1.01% -0.69% 3640.24 ms +0.77% -0.32% 0.2%
mediaProcessingJpegToAvif 2550.74 ms +0.48% -0.57% 2559.1 ms +0.58% -1.27% -0.33%

media-upload

Metric 627e42d trunk % Change
jpegUploadProcessing 1442.42 ms +2.58% -0.6% 1430.55 ms +0.98% -0.27% 0.83%
pngUploadProcessing 184.91 ms +2.68% -2.63% 187.06 ms +3.73% -4.66% -1.15%
largeJpegUploadProcessing 1435.85 ms +2.37% -0.83% 1436.3 ms +0.9% -0.66% -0.03%
multipleImageUploadProcessing 1501.34 ms +0.98% -1.23% 1476.99 ms +0.42% -1.29% 1.65%

post-editor

Metric 627e42d trunk % Change
serverResponse 485.09 ms +3.01% -8.26% 452.32 ms +5.69% -5.08% 7.24%
firstPaint 444.6 ms +9.01% -9.69% 394.84 ms +8.24% -4.55% 12.6%
domContentLoaded 799.23 ms +4.09% -0.35% 802.03 ms +2.12% -1.69% -0.35%
loaded 800.17 ms +4.11% -0.35% 802.92 ms +2.15% -1.69% -0.34%
firstContentfulPaint 448.01 ms +8.18% -2.72% 451.49 ms +1.34% -2.89% -0.77%
firstBlock 2198.12 ms +8.04% -2.3% 2169.04 ms +1.04% -0.92% 1.34%
type 15.98 ms +1.81% -9.07% 16.18 ms +5.25% -8.28% -1.24%
typeWithoutInspector 16.49 ms +4.85% -4.85% 18.94 ms +18.27% -12.62% -12.94%
typeWithTopToolbar 20.96 ms +8.73% -4.63% 21.45 ms +3.36% -9.74% -2.28%
typeContainer 7.56 ms +2.51% -9.66% 7.44 ms +5.24% -7.8% 1.61%
focus 102.57 ms +6.23% -5.42% 104.96 ms +4.99% -6.47% -2.28%
firstFocus 256.09 ms +0% -0% 257.94 ms +0% -0% -0.72%
selectAll 376.56 ms +0.93% -4.44% 395.23 ms +3.42% -3.68% -4.72%
undo 26.99 ms +8.74% -5.15% 26.96 ms +5.56% -5.42% 0.11%
listViewOpen 62.85 ms +10.74% -11.5% 62.96 ms +7.12% -14.85% -0.17%
inserterOpen 38.56 ms +10.79% -8.61% 37.53 ms +2.53% -5.89% 2.74%
inserterHover 10.8 ms +12.31% -9.72% 10.36 ms +8.4% -9.17% 4.25%
inserterSearch 8.29 ms +8.44% -7.84% 7.51 ms +12.92% -7.06% 10.39%
loadPatterns 620.12 ms +2.62% -2.46% 594.03 ms +9.16% -4.39% 4.39%
wpTotal 475.52 ms +2.71% -8.42% 442.79 ms +5.79% -5.2% 7.39%
wpMemoryUsage 14.81 MB +0% -0% 14.76 MB +0% -0% 0.33%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 627e42d trunk % Change
serverResponse 257.51 ms +1.59% -5.35% 239.62 ms +7.06% -6.56% 7.47%
firstPaint 308.64 ms +4.53% -14.99% 269.85 ms +7.77% -7.1% 14.37%
domContentLoaded 551.83 ms +4.45% -4.08% 510.01 ms +5.34% -0.6% 8.2%
loaded 552.65 ms +4.45% -4.08% 510.66 ms +5.34% -0.6% 8.22%
firstContentfulPaint 318.72 ms +4.64% -3.7% 294.6 ms +2.69% -1.29% 8.19%
firstBlock 1700.48 ms +3.21% -1.76% 1597.72 ms +4.05% -1.54% 6.43%
type 13.84 ms +15.68% -11.85% 11.4 ms +6.58% -6.58% 21.4%
navigate 78.71 ms +11.92% -6.12% 74.83 ms +3.34% -5.79% 5.19%
loadPatterns 886.13 ms +11.05% -12.39% 893.95 ms +4.03% -4.81% -0.87%
loadPages 905.8 ms +4.94% -1.71% 908.16 ms +1.93% -0.91% -0.26%
wpTotal 250.63 ms +1.86% -5.42% 233.47 ms +7.08% -6.72% 7.35%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

92368d2 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.

Navigates the list via UP/DOWN arrow keys from action buttons in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' }) with timeout 5000ms
  - waiting for getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
    14 × locator resolved to <button type="button" tabindex="-1" class="components-button is-small" id="view-list-0-173-primary-action-edit-post">Edit</button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:243: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-ff397679-821f-4eb0-9991-757b316d7f7a" data-block="ff397679-821f-4eb0-9991-757b316d7f7a" 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

92368d2 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
Resolves the conflicts with #86923, which moved the press code from
pointerdown to mousedown: the focus check stays in pointerdown, and both
iOS tests are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ellatrix
ellatrix merged commit d57e2b3 into trunk Nov 24, 2026
83 of 84 checks passed
@ellatrix
ellatrix deleted the fix/ios-retap-after-page-blur branch November 24, 2026 01:36
@github-actions github-actions Bot added this to the Gutenberg 24.6 milestone Nov 24, 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 d57e2b33648fe1a9f800f83651bf1a2077be62b5

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

Mamaduka pushed a commit that referenced this pull request Nov 24, 2026
@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 24, 2026
wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Nov 24, 2026
This updates the pinned commit hash of the Gutenberg repository from `efd7722f89ebb8abfc3607fffdd86f5e34afbd9c` to `c5bdc7f4898ec98114cdccbe1cacec7a979b85cc` (head of the `wp/7.2` branch).

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

- Interactivity API: Align unsupported `data-wp-html` bindings with PHP (WordPress/gutenberg#86968) (WordPress/gutenberg#87015)
- E2E: Select the link preview by URL in the keyboard test (WordPress/gutenberg#87053) (WordPress/gutenberg#87102)
- Update the Update icon. (WordPress/gutenberg#87088) (WordPress/gutenberg#87139)
- Editor: Hide parent controls for non-hierarchical post types (WordPress/gutenberg#85679) (WordPress/gutenberg#87150)
- SearchableChipSelect: Use a single string for the chips toolbar label (WordPress/gutenberg#87219) (WordPress/gutenberg#87275)
- E2E Tests: Switch the theme before the other setup resets (WordPress/gutenberg#86278)
- Abilities: Accept a date-time without an offset in the `date-time` schema format (WordPress/gutenberg#86845) (WordPress/gutenberg#87311)
- Fix iOS tap into a quote jumping to the caret's block when it's off screen (WordPress/gutenberg#86923)
- Place the caret on a tap after the keyboard is swiped away (WordPress/gutenberg#87182)
- Writing flow: Keep the browser from deleting into a neighbouring block (WordPress/gutenberg#87188)
- Writing flow: Bring back the header iOS slides off screen, once the canvas stops scrolling (WordPress/gutenberg#87316)
- List: Drag a list item by its bullet again (WordPress/gutenberg#85801)
- MediaEdit: Show the image preview when the MIME type is empty (WordPress/gutenberg#87207) (WordPress/gutenberg#87326)
- Block Editor: Fix block hover outline flicker when moving between elements of a block (WordPress/gutenberg#86852) (WordPress/gutenberg#87328)

Developed in: #16187

Props peterwilsoncc, mamaduka, linewebdigital, abhishekfdd, oandregal, jorgefilipecosta.
See #66340.
Fixes #66428.

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

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

- Interactivity API: Align unsupported `data-wp-html` bindings with PHP (WordPress/gutenberg#86968) (WordPress/gutenberg#87015)
- E2E: Select the link preview by URL in the keyboard test (WordPress/gutenberg#87053) (WordPress/gutenberg#87102)
- Update the Update icon. (WordPress/gutenberg#87088) (WordPress/gutenberg#87139)
- Editor: Hide parent controls for non-hierarchical post types (WordPress/gutenberg#85679) (WordPress/gutenberg#87150)
- SearchableChipSelect: Use a single string for the chips toolbar label (WordPress/gutenberg#87219) (WordPress/gutenberg#87275)
- E2E Tests: Switch the theme before the other setup resets (WordPress/gutenberg#86278)
- Abilities: Accept a date-time without an offset in the `date-time` schema format (WordPress/gutenberg#86845) (WordPress/gutenberg#87311)
- Fix iOS tap into a quote jumping to the caret's block when it's off screen (WordPress/gutenberg#86923)
- Place the caret on a tap after the keyboard is swiped away (WordPress/gutenberg#87182)
- Writing flow: Keep the browser from deleting into a neighbouring block (WordPress/gutenberg#87188)
- Writing flow: Bring back the header iOS slides off screen, once the canvas stops scrolling (WordPress/gutenberg#87316)
- List: Drag a list item by its bullet again (WordPress/gutenberg#85801)
- MediaEdit: Show the image preview when the MIME type is empty (WordPress/gutenberg#87207) (WordPress/gutenberg#87326)
- Block Editor: Fix block hover outline flicker when moving between elements of a block (WordPress/gutenberg#86852) (WordPress/gutenberg#87328)

Developed in: WordPress/wordpress-develop#16187

Props peterwilsoncc, mamaduka, linewebdigital, abhishekfdd, oandregal, jorgefilipecosta.
See #66340.
Fixes #66428.
Built from https://develop.svn.wordpress.org/trunk@65751


git-svn-id: http://core.svn.wordpress.org/trunk@64781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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] 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.

2 participants