[web] Preserve text field focus across tab switches#188738
Merged
auto-submit[bot] merged 7 commits intoJul 10, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to defer closing the text input connection when the document loses focus, addressing cases like browser tab switching where a blur event occurs before the visibility state changes. A 100ms timer is used to delay the connection closure, which is cancelled if the document becomes hidden or regains focus. Corresponding unit tests are added to verify these scenarios. The review feedback recommends adding documentation to the new test-override fields to comply with the style guide, and cancelling the pending blur timer within the enable method to prevent potential race conditions.
flutter-zl
force-pushed
the
fix-web-text-field-focus-tab-switch
branch
2 times, most recently
from
June 29, 2026 19:32
e8e05e9 to
70e0230
Compare
flutter-zl
force-pushed
the
fix-web-text-field-focus-tab-switch
branch
from
June 29, 2026 21:11
70e0230 to
3142716
Compare
flutter-zl
force-pushed
the
fix-web-text-field-focus-tab-switch
branch
from
June 30, 2026 17:22
eb25d3d to
1c0960a
Compare
flutter-zl
force-pushed
the
fix-web-text-field-focus-tab-switch
branch
from
July 7, 2026 17:45
25f6600 to
f8014cc
Compare
This was referenced Jul 10, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Jul 10, 2026
flutter/flutter@dc2a870...f7b66f3 2026-07-10 [email protected] [iOS][test] Fix VSyncClient display link deallocation test on iOS 27 (flutter/flutter#188627) 2026-07-10 [email protected] Fix broken listener code in WindowScope (flutter/flutter#189208) 2026-07-10 [email protected] [web] Preserve text field focus across tab switches (flutter/flutter#188738) 2026-07-10 [email protected] [Impeller] Recycle HostBuffer arena entries only after GPU completion (flutter/flutter#188965) 2026-07-10 [email protected] Assert TextStyle height is not NaN (flutter/flutter#186617) 2026-07-10 [email protected] Roll Fuchsia Test Scripts from dFkTCiDxEtPxYK5Nn... to wLST_A-xfOeGT_5mj... (flutter/flutter#189259) 2026-07-10 [email protected] Roll Dart SDK from a11fb7ed40a5 to 0fc1668c4af4 (5 revisions) (flutter/flutter#189257) 2026-07-10 [email protected] Adds a missing `await` to a `FutureOr` (flutter/flutter#189198) 2026-07-10 [email protected] [web] Repair RenderCanvas CSS size drift (flutter/flutter#188797) 2026-07-10 [email protected] Roll Fuchsia Test Scripts from s5_gZFJ8De9AJalTw... to dFkTCiDxEtPxYK5Nn... (flutter/flutter#189215) 2026-07-10 [email protected] Roll Fuchsia Linux SDK from QcRFUtvCw2EobfJ8s... to czpzDg9ABY2oKLAOY... (flutter/flutter#189222) 2026-07-10 [email protected] Update Depdencies Used By `flutter_engine_group_performance` (flutter/flutter#189229) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #178109
Problem
On Flutter Web, a focused
TextFormFieldloses focus after switching to another browser tab and returning. The browser blurs the hidden text input before reporting the page as hidden, so the engine closes the text input connection too early.Fix
Defer closing the text input connection when the document has lost focus and
relatedTargetis null. If the page becomes hidden, keep the connection alive so focus can recover on tab resume. If the page stays visible, close as before to preserve window and iframe blur behavior. The delayed callback also skips closing if the document quickly regains focus.Demo
Steps: focus the text field, type text, switch to another browser tab, then return. Before:
Focusedbecomesno. After:Focusedreturns toyes.