Repository navigation
Conversation
Pressing a block that is edited on its own element while the canvas is the editing host focused the field with the caret first. When that field was scrolled out of view, iOS scrolled to it, and the tap landed on another block. Focus the pressed field instead, and for a touch only on pointerup, once it is a tap rather than a scroll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +51 B (0%) Total Size: 8.66 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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. List in
|
A touch may become a scroll, so the press code now runs for a mouse only. On iOS, moving focus soon after a tap makes WebKit repeat the tap at the page's top left corner, moving the caret out of the field. Put it back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The browser places a mouse's caret in mousedown's default action, so the press code runs there, with no pointer type check. A touch's mousedown comes once it is known to be a tap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What?
On iOS, tapping a block that is edited as its own field, like a paragraph in a quote or an image caption, now places the caret there when the caret was in a block that is scrolled out of view. Before, the page jumped and the tap landed on a different block.
Why?
A tap from a block the canvas edits (a heading) into a block edited as its own field (a paragraph in a quote) has to move focus from the canvas to that field. On iOS, moving focus soon after a tap makes WebKit reset its text gestures, and UIKit then repeats the tap at the page's top left corner, which moves the caret there. #86549 worked around this by moving focus on touch start, before the tap, but then it cannot tell a tap from a scroll, and it focused the field with the caret: when that field was off screen, iOS scrolled to it, ignoring
preventScroll, so the tap landed on another block.How?
useClickSelectionmoves focus onmousedowninstead ofpointerdown. A mouse places the caret inmousedown's default action, so this is still in time for it, and a touch only firesmousedownonce it is a tap. Nothing runs on touch start, so taps and scrolls are native.useRestoreTapCaretremembers the caret when focus moves from the canvas to a field, and puts it back if the caret then leaves the focused field. Only the repeated tap does that, since it changes the selection but not focus. It can go once WebKit fixes the repeat.Testing Instructions
Open in Playground: a post with a heading, a quote and paragraphs below them, open in the editor.
On trunk, the page jumps and the text goes elsewhere. With this PR, it goes at the start of the quote.
Also check what #86279 fixed: tap the end of a heading, then the quote, and type. The text goes into the quote.
New iOS test
testTapIntoQuoteWithCaretOffScreenPlacesCaretintest/ios/SafariTests/SelectionTests.swift: it fails on trunk ("The quote did not get the X"). With this change, it and the #86279 testtestTapFromHeadingIntoQuoteWithoutIframePlacesCaretpass 10 of 10 runs on iOS 27 and on iOS 26.5.Testing Instructions for Keyboard
Unchanged: the change only affects pressing with a pointer.
Screenshots or screencast
iOS 27 simulator, recorded while
testTapIntoQuoteWithCaretOffScreenPlacesCaretruns: the caret is in the last paragraph, the page is scrolled up (sped up 8x), then the test taps the quote and types X.before-trunk.mp4
after-pr.mp4
Use of AI Tools
Investigated and written with Claude Code: reproduced on an iPhone, wrote the iOS test, and ran the iOS and end-to-end tests.
🤖 Generated with Claude Code