Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
d76132b to
4542a58
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to reopen and restore a closed text input connection when an iOS text input view regains first responder status, preventing text from being discarded when system UI sheets (such as AutoFill) are dismissed. The changes are implemented across the iOS platform code and the Dart framework, accompanied by unit and widget tests. Feedback on the tests identifies a discrepancy in testTheConnectionIsOnlyReopenedOnce where the test logic does not align with its explanatory comment regarding multiple focus acquisitions without an intervening resign.
|
Ah for a second I thought this was a duplicate of #191781 but looks like this one allows the system to change the text inside of the input field as soon as the platform text field becomes the first responder (while with #191781 the flutter text field won't receive the text because it has not regained focus so there's no active connection yet, and also it may create a new |
|
@LongCatIsLooong yes, this restores the connection instead of creating a new one. I initially tried something like in #191781, but it was not enough to fix this issue |
When iOS restores first responder to a text input view whose connection it had reported closed, flutter#191781 now tells the framework, which re-requests focus from TextInputClient.onFocusReceived. The client then attaches a new connection, and that connection carries a new client id. iOS delivers the text picked from an AutoFill sheet such as "Hide My Email" immediately after restoring first responder, using the client id it already holds. That delivery arrives before a newly attached connection exists, so the client id check in TextInput._handleTextInputInvocation discards it and the field stays empty. Take the reported connection back instead of letting a new one attach, so the id the platform is using stays valid and the text is applied. Fixes flutter#157495
5de7105 to
328d3a5
Compare
|
@LongCatIsLooong I aligned my solution to the one that was merged in: #191781 |
When iOS restores first responder to a text input view whose connection it had reported closed, #191781 now reports that to the framework, and
EditableTextre-requests focus fromTextInputClient.onFocusReceived. The client then attaches a new connection, which carries a new client id.That is sufficient for #189051, where nothing is delivered during the switch. It is not sufficient for the AutoFill sheets: iOS delivers the text the user picked immediately after restoring first responder, using the client id it already holds. That delivery arrives before a newly attached connection exists, so the client id check in
TextInput._handleTextInputInvocationdiscards it and the field stays empty.This takes the reported connection back instead of letting a new one attach, so the id the platform is using stays valid and the text is applied.
onFocusReceivedstill returns the same bool #191781 relies on to decide whether to resign the responder.Framework-only; no engine changes.
Fixes #157495
Verification
Measured on a physical iPhone (iOS 26.5), with a locally built engine, using a minimal repro — a single
TextFieldwithkeyboardType: TextInputType.emailAddressandautofillHints: [AutofillHints.email]:Both runs used the same engine build, so the only variable is this patch.
Instrumented trace of the failing case (swizzled
FlutterTextInputView, unpatched framework) — iOS restores first responder and inserts the address 0.5 ms later, under the original client id:Tests: 2 added in
editable_text_test.dartcovering the restore path and a restore for a different client id.editable_text_test.dart+text_input_test.dart+autofill_test.dart+autofill_group_test.dart: 608 passing.Pre-launch Checklist
///).