From 393748e8c50592d4af5ddbc8164d4f08134f5749 Mon Sep 17 00:00:00 2001 From: Taha Tesser Date: Mon, 19 Feb 2024 11:36:32 +0200 Subject: [PATCH] Revert "Fix iOS password autofill prompt dismissal causes layout to resize (#50364)" (flutter/engine#50760) This reverts commit 5f93393312241b5616a9253b7bf9cd82b5d77dda. Reverts https://github.com/flutter/engine/pull/50364 fixes https://github.com/flutter/flutter/issues/143642 *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../framework/Source/FlutterViewController.mm | 9 ---- .../Source/FlutterViewControllerTest.mm | 54 ------------------- 2 files changed, 63 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index f92830c713..64d53602ad 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -1520,15 +1520,6 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch) BOOL keyboardAnimationIsCompounding = self.keyboardAnimationIsShowing == keyboardWillShow && _keyboardAnimationVSyncClient != nil; - // Avoid triggering startKeyBoardAnimation when keyboard notifications are triggered - // by the dismissal of password autofill prompt. When this happens, there is - // no keyboard on the screen and FlutterTextInputViewAccessibilityHider is nil. - FlutterTextInputPlugin* textInputPlugin = self.engine.textInputPlugin; - UIView* textInputHider = [[textInputPlugin textInputView] superview]; - if (keyboardWillShow && textInputHider == nil) { - return; - } - // Mark keyboard as showing or hiding. self.keyboardAnimationIsShowing = keyboardWillShow; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm index afd89130af..a68a55287f 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm @@ -305,18 +305,6 @@ extern NSNotificationName const FlutterViewControllerWillDealloc; FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; - FlutterMethodCall* setClientCall = - [FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient" - arguments:@[ @(123), @{@"autocorrect" : @YES} ]]; - [engine.textInputPlugin handleMethodCall:setClientCall - result:^(id _Nullable result){ - }]; - - // Check if FlutterTextInputViewAccessibilityHider exists. - FlutterTextInputPlugin* textInputPlugin = engine.textInputPlugin; - UIView* textInputHider = [[textInputPlugin textInputView] superview]; - XCTAssertNotNil(textInputHider); - FlutterViewController* viewControllerMock = OCMPartialMock(viewController); UIScreen* screen = [self setUpMockScreen]; CGRect viewFrame = screen.bounds; @@ -2200,46 +2188,4 @@ extern NSNotificationName const FlutterViewControllerWillDealloc; XCTAssertNil(viewController.keyboardAnimationVSyncClient); } -- (void)testAvoidKeyboardAnimationWhenFlutterTextInputViewAccessibilityHiderIsNil { - FlutterEngine* engine = [[FlutterEngine alloc] init]; - [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine - nibName:nil - bundle:nil]; - - FlutterViewController* viewControllerMock = OCMPartialMock(viewController); - UIScreen* screen = [self setUpMockScreen]; - CGRect viewFrame = screen.bounds; - [self setUpMockView:viewControllerMock - screen:screen - viewFrame:viewFrame - convertedFrame:viewFrame]; - - CGFloat screenHeight = screen.bounds.size.height; - CGFloat screenWidth = screen.bounds.size.height; - - // Check if FlutterTextInputViewAccessibilityHider is nil. - FlutterTextInputPlugin* textInputPlugin = engine.textInputPlugin; - UIView* textInputHider = [[textInputPlugin textInputView] superview]; - XCTAssertNil(textInputHider); - - // Start show keyboard animation. - CGRect showKeyboardBeginFrame = CGRectMake(0, screenHeight, screenWidth, 250); - CGRect showKeyboardEndFrame = CGRectMake(0, screenHeight - 250, screenWidth, 250); - NSNotification* fakeNotification = - [NSNotification notificationWithName:UIKeyboardWillChangeFrameNotification - object:nil - userInfo:@{ - @"UIKeyboardFrameBeginUserInfoKey" : @(showKeyboardBeginFrame), - @"UIKeyboardFrameEndUserInfoKey" : @(showKeyboardEndFrame), - @"UIKeyboardAnimationDurationUserInfoKey" : @(0.25), - @"UIKeyboardIsLocalUserInfoKey" : @(YES) - }]; - - viewControllerMock.targetViewInsetBottom = 0; - [viewControllerMock handleKeyboardNotification:fakeNotification]; - BOOL isShowingAnimation = viewControllerMock.keyboardAnimationIsShowing; - XCTAssertFalse(isShowingAnimation); -} - @end