From ff20e873d163dd9ad1572019420860b31d3767ae Mon Sep 17 00:00:00 2001 From: Simon McLoughlin Date: Wed, 5 Jun 2024 16:32:40 +0100 Subject: [PATCH] Bug fix: crash when trying to ungroup/group collectibles while searching. Now cancels search and reloads --- .../CollectiblesCollectionsViewController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Kukai Mobile/Modules/Collectibles/CollectiblesCollectionsViewController.swift b/Kukai Mobile/Modules/Collectibles/CollectiblesCollectionsViewController.swift index 205e8102..d2fab6f9 100644 --- a/Kukai Mobile/Modules/Collectibles/CollectiblesCollectionsViewController.swift +++ b/Kukai Mobile/Modules/Collectibles/CollectiblesCollectionsViewController.swift @@ -20,6 +20,7 @@ class CollectiblesCollectionsViewController: UIViewController, UICollectionViewD private var movingToDetails = false private var textFieldDone = false private var lastSearchedTerm: String? = nil + private var ignoreNextTextFieldDidEnd = true public weak var delegate: UIViewController? = nil @@ -92,6 +93,12 @@ class CollectiblesCollectionsViewController: UIViewController, UICollectionViewD } func needsRefreshFromParent() { + if viewModel.isSearching { + self.clearSearchTextField() + viewModel.isSearching = false + ignoreNextTextFieldDidEnd = true + } + refreshingFromParent = true viewModel.refresh(animate: true) } @@ -174,11 +181,12 @@ extension CollectiblesCollectionsViewController: ValidatorTextFieldDelegate { } public func textFieldDidEndEditing(_ textField: UITextField) { - if !movingToDetails && !textFieldDone { + if !movingToDetails && !textFieldDone && !ignoreNextTextFieldDidEnd { self.hideSearchingUI() } textFieldDone = false + ignoreNextTextFieldDidEnd = false } func textFieldShouldClear(_ textField: UITextField) -> Bool {