Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Send connectionClosed message when resignFirstResponder to ensure framework focus state is correct. #40703

Merged
merged 6 commits into from Mar 30, 2023

Conversation

luckysmg
Copy link
Contributor

@luckysmg luckysmg commented Mar 28, 2023

Fix:

Before this patch:

see in linked issue.

After this patch:

iPhone iPad

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM % nits

@cyanglaz
Copy link
Contributor

cyanglaz commented Mar 28, 2023

Blocked by:
flutter/flutter#123523

Did you mean to link to a framework PR instead?

@LongCatIsLooong
Copy link
Contributor

There's already this message: https://master-api.flutter.dev/flutter/services/TextInputClient/connectionClosed.html

@@ -1043,7 +1043,8 @@ - (BOOL)canBecomeFirstResponder {
- (BOOL)resignFirstResponder {
BOOL success = [super resignFirstResponder];
if (success) {
[self.textInputDelegate flutterTextInputViewDidResignFirstResponder:self];
[self.textInputDelegate flutterTextInputViewDidResignFirstResponder:self
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Looks like this one will be called when either the Flutter framework or UIKit tells the input view to give up its first responder status. It seems redundant for the former since there's no need to inform the Flutter framework when it is the one that initiated the focus change.

Copy link
Contributor Author

@luckysmg luckysmg Mar 29, 2023

Choose a reason for hiding this comment

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

Yes. When framework close the keyboard first, this will send a msg to framework but will be handled return by

https://github.com/flutter/flutter/blob/659ba386f6d045690f9783c79fe5d320fb7847a1/packages/flutter/lib/src/services/text_input.dart#L1788

And only when platform starts to unfocus, the _currentConnection!._client.connectionClosed(); will be called.

Currently, engine side doens't have a good simple way to know the original focus/unfocus signal is from framework or from platform, this maybe can be done by set some var like BOOL sendFromFramework to judge, but I think that will be overkill........(Maybe I missed something that can judge this)

So I think this cost can be acceptable? ^_^

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that makes sense the old connection is already torn down by the framework so messages associated with the old client id will be thrown away.

@luckysmg
Copy link
Contributor Author

luckysmg commented Mar 29, 2023

There's already this message: https://master-api.flutter.dev/flutter/services/TextInputClient/connectionClosed.html

Oh.thx for reminding me that. I will try invoke that method to unfocus.

@luckysmg luckysmg changed the title [iOS] Send unfocus message to framework to ensure focus state is correct. [iOS] Send connectionClosed message when resignFirstResponder to ensure framework focus state is correct. Mar 29, 2023
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

This LGTM, would like @LongCatIsLooong to confirm concerns were addressed.

@luckysmg
Copy link
Contributor Author

Thx everyone reviewing this. Applying label for merging O(∩_∩)O

@luckysmg luckysmg added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 30, 2023
@auto-submit auto-submit bot merged commit bad50dd into flutter:main Mar 30, 2023
37 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 30, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2023
luckysmg added a commit that referenced this pull request Apr 10, 2023
…esponder to ensure framework focus state is correct. (#40703)" (#40777)"

This reverts commit 75fabbe.
exaby73 pushed a commit to NevercodeHQ/flutter that referenced this pull request Apr 17, 2023
…er to ensure framework focus state is correct. (flutter/engine#40703) (flutter#123753)

Roll Flutter Engine from 7dcbf0edf6b4 to bad50ddc9f3d (1 revision)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-ios
Projects
None yet
5 participants