Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[iOS] Fix view removal process for AutofillContextAction.cancel #57209

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2675,8 +2675,11 @@ - (void)hideTextInput {
[self removeEnableFlutterTextInputViewAccessibilityTimer];
_activeView.accessibilityEnabled = NO;
[_activeView resignFirstResponder];
[_activeView removeFromSuperview];
[_inputHider removeFromSuperview];
// Removes the focus from the `_activeView` (UIView<UITextInput>)
// when the user stops typing (keyboard is hidden).
// For more details, refer to the discussion at:
// https://github.com/flutter/engine/pull/57209#discussion_r1905942577
[self cleanUpViewHierarchy:YES clearText:YES delayRemoval:NO];
}

- (void)triggerAutofillSave:(BOOL)saveEntries {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2691,6 +2691,27 @@ - (void)testInitialActiveViewCantAccessTextInputDelegate {
XCTAssertNil(textInputPlugin.activeView.textInputDelegate);
}

- (void)testAutoFillDoesNotTriggerOnHideButTriggersOnCommit {
// Regression test for https://github.com/flutter/flutter/issues/145681.
NSMutableDictionary* configuration = self.mutableTemplateCopy;
[configuration setValue:@{
@"uniqueIdentifier" : @"field1",
@"hints" : @[ UITextContentTypePassword ],
@"editingValue" : @{@"text" : @""}
}
forKey:@"autofill"];
[configuration setValue:@[ [configuration copy] ] forKey:@"fields"];

[self setClientId:123 configuration:configuration];
XCTAssertEqual(self.viewsVisibleToAutofill.count, 1ul);

[self setTextInputHide];
// Before the fix in https://github.com/flutter/engine/pull/57209, it was 0ul.
XCTAssertEqual(self.viewsVisibleToAutofill.count, 1ul);

[self commitAutofillContextAndVerify];
}

#pragma mark - Accessibility - Tests

- (void)testUITextInputAccessibilityNotHiddenWhenShowed {
Expand Down
Loading