From 4876918b383b5be5fa9e82fde769daa7bd85a573 Mon Sep 17 00:00:00 2001 From: amddg44 Date: Wed, 20 Nov 2024 16:04:36 +0100 Subject: [PATCH] Fix autofill search authentication looping (#3598) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task/Issue URL: https://app.asana.com/0/1203822806345703/1208755477452311/f Tech Design URL: CC: **Description**: Fixes an issue where if the Passwords screen is dismissed while in search mode, UISearchController prevented the Passwords screen from being released from memory. I’ve also found and fixed a memory leak with the autofill breakage reporter. --- ...ofillLoginSettingsListViewController.swift | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/AutofillLoginSettingsListViewController.swift b/DuckDuckGo/AutofillLoginSettingsListViewController.swift index 11e2934c0a..49884b187b 100644 --- a/DuckDuckGo/AutofillLoginSettingsListViewController.swift +++ b/DuckDuckGo/AutofillLoginSettingsListViewController.swift @@ -228,6 +228,7 @@ final class AutofillLoginSettingsListViewController: UIViewController { super.viewDidLoad() title = UserText.autofillLoginListTitle extendedLayoutIncludesOpaqueBars = true + navigationController?.presentationController?.delegate = self setupCancellables() installSubviews() installConstraints() @@ -449,6 +450,11 @@ final class AutofillLoginSettingsListViewController: UIViewController { } } + private func dismissSearchIfRequired() { + guard searchController.isActive else { return } + searchController.dismiss(animated: false) + } + private func presentDeleteConfirmation(for title: String, domain: String) { let message = title.isEmpty ? UserText.autofillLoginListLoginDeletedToastMessageNoTitle : UserText.autofillLoginListLoginDeletedToastMessage(for: title) @@ -805,11 +811,11 @@ final class AutofillLoginSettingsListViewController: UIViewController { let cell = tableView.dequeueCell(ofType: AutofillBreakageReportTableViewCell.self, for: indexPath) let contentView = AutofillBreakageReportCellContentView(onReport: { [weak self] in - guard let alert = self?.viewModel.createBreakageReporterAlert() else { + guard let self = self, let alert = self.viewModel.createBreakageReporterAlert() else { return } - self?.present(controller: alert, fromView: tableView) + self.present(controller: alert, fromView: self.tableView) Pixel.fire(pixel: .autofillLoginsReportConfirmationPromptDisplayed) }) @@ -1125,6 +1131,16 @@ extension AutofillLoginSettingsListViewController: UISearchBarDelegate { } } +// MARK: UIAdaptivePresentationControllerDelegate + +extension AutofillLoginSettingsListViewController: UIAdaptivePresentationControllerDelegate { + + func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { + dismissSearchIfRequired() + } + +} + // MARK: Keyboard extension AutofillLoginSettingsListViewController {