Skip to content

Reland "[web] Keep the keyboard up during an iOS caret drag" - #190942

Merged
auto-submit[bot] merged 25 commits into
flutter:masterfrom
flutter-zl:reland_189744
Sep 18, 2026
Merged

auto-submit[bot] merged 25 commits into
flutter:masterfrom
flutter-zl:reland_189744

Conversation

@flutter-zl

@flutter-zl flutter-zl commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems engine flutter/engine related. See also e: labels. platform-web Web applications specifically f: focus Focus traversal, gaining or losing focus team-web Owned by Web platform team labels Aug 11, 2026
@flutter-zl
flutter-zl marked this pull request as ready for review August 11, 2026 18:47

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@flutter-zl flutter-zl added the CICD Run CI/CD label Aug 11, 2026
Renzo-Olivares
Renzo-Olivares previously approved these changes Aug 11, 2026

@Renzo-Olivares Renzo-Olivares left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 11, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 11, 2026
@auto-submit

auto-submit Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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.

@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 31, 2026
@auto-submit

auto-submit Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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.

@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 1, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 1, 2026
@auto-submit

auto-submit Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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.

@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 1, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 1, 2026
@auto-submit

auto-submit Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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.

Renzo-Olivares
Renzo-Olivares previously approved these changes Sep 11, 2026

@Renzo-Olivares Renzo-Olivares left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2026
@auto-submit

auto-submit Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

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.

@Renzo-Olivares Renzo-Olivares left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RE-LGTM

@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 17, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 17, 2026
Merged via the queue into flutter:master with commit 634b0ed Sep 18, 2026
22 of 23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 18, 2026
bkonyi pushed a commit to bkonyi/flutter that referenced this pull request Oct 5, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD engine flutter/engine related. See also e: labels. f: focus Focus traversal, gaining or losing focus platform-web Web applications specifically team-web Owned by Web platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web][iOS 27] Keyboard dismisses when long-press-dragging the text selection caret

2 participants