Repository navigation
Reland "[web] Keep the keyboard up during an iOS caret drag" - #190942
Conversation
There was a problem hiding this comment.
Code Review
This pull request defers the reporting of view-unfocused and text connection close events on iOS Safari during transient blurs caused by native caret or selection dragging, preventing the keyboard from dismissing mid-gesture. If refocusing occurs within a 100ms delay, the deferred actions are canceled. Unit tests are added to verify these behaviors. The review feedback suggests adding a null check for activeDomElement to avoid incorrect equality matches when both elements are null, and canceling any pending focusout timer during non-deferred focus changes to prevent obsolete state overrides.
|
autosubmit label was removed for flutter/flutter/190942, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/190942, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/190942, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/190942, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/190942, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
This switches the Safari Web engine CI suites (`Mac run safari suites`) to run on `Mac-26.6` LUCI bots (matching the `Mac-26.6` dimension convention in flutter#193317) and enables the 4 WasmGC / Skwasm Safari suites now that Safari 26 (with Wasm `js-string` builtins) ships on macOS 26.6.2 bots (flutter#192559 / flutter#192572): - `safari-dart2wasm-canvaskit-engine` - `safari-dart2wasm-skwasm-ui` - `safari-coi-dart2wasm-skwasm-ui` - `safari-coi-dart2wasm-skwasm-skwasm` ### Safari 26 & WebDriver Focus Test Updates Running `Mac run safari suites` on `Mac-26.6` exposed two Safari 26 CSS `outline` serialization differences and one test that depended on `Safari.app` holding macOS WindowServer foreground focus under `safaridriver`: 1. **`text_editing_test.dart` (`text editing styles invisible element`)**: Safari 26 serializes inline `outline: none` on `input.style.outline` as `'medium'` (matching `input.style.border` immediately below it). 2. **`view_embedder/style_manager_test.dart` (`attachGlobalStyles hides the outline when focused`)**: Safari 26 serializes `getComputedStyle(element).outline` in canonical CSSOM order (`'0px none rgb(0, 0, 0)'` instead of `'rgb(0, 0, 0) none 0px'`). Additionally, in WebKit `:focus` only matches when `domDocument.hasFocus()` is `true`; when `Safari.app` is not the frontmost macOS WindowServer app (`!domDocument.hasFocus()`), WebKit returns the unfocused initial outline (`'3px none rgb(0, 0, 0)'`). 3. **`platform_dispatcher/view_focus_binding.dart` & `view_focus_binding_test.dart` (`works even if focus is changed in the middle of a blur call`)**: Use `_documentHasFocus` (introduced in flutter#190942 for `debugViewFocusDocumentHasFocusOverride`) in `ViewFocusBinding._handleFocusout` (`wasFocusInvoked`) and set `debugViewFocusDocumentHasFocusOverride = true` in the test so it does not flake when the `safaridriver` window is unfocused in WindowServer. Fixes flutter#193833 Fixes flutter#193834 Part of flutter#192559 Part of flutter#192572
Fixes #189744
Reland of #190014, reverted in #190926.
Cause: three of the new tests dispatch a real input.blur(), but desktop Safari uses SafariDesktopTextEditingStrategy, which does not subscribe to blur, so handleBlur never ran. Real iOS does subscribe, so the fix itself was unaffected.
Delta: one test-only commit adding skip: isSafari to those three tests. No production change.
Problem
On iOS 27, long-press-dragging the selection caret in a Web TextField dismisses the keyboard mid-gesture. WebKit transiently blurs the hidden input with a null relatedTarget while the document keeps focus, then refocuses it a frame later,and the engine reacted to that blink on two listeners that each tore the input down. A plain input ignores the same blur, so the cause is Flutter's reaction, not a WebKit limitation.
Fix
On iOS both listeners now defer their teardown by 100ms and cancel it if the input refocuses, mirroring the existing #155265 deferred close. Done and tap-away never refocus so they still close, and the deferral is narrowed to the exact drag signature so every other focus transition is unaffected.
Demo
Before: https://flutter-demo-52-before.web.app/ (keyboard dismisses mid caret drag)
After: https://flutter-demo-52-after.web.app/ (keyboard stays up)
Repro on iOS 27 Safari: tap the field to raise the keyboard, then long-press and drag the selection caret. Before dismisses; after stays up. Done and tap-away still dismiss.