diff --git a/MacPass/MPContextBarViewController.m b/MacPass/MPContextBarViewController.m index ee2bb014..4dccb960 100644 --- a/MacPass/MPContextBarViewController.m +++ b/MacPass/MPContextBarViewController.m @@ -99,7 +99,7 @@ typedef NS_ENUM(NSUInteger, MPContextTab) { - (void)_didChangeCurrentItem:(NSNotification *)notification { MPDocument *document = [notification object]; BOOL showTrash = document.useTrash && (document.selectedGroup == document.trash || [document isItemTrashed:document.selectedItem]); - if(showTrash) { + if(showTrash && ! document.hasSearch) { self.activeTab = MPContextTabTrash; [self _updateBindings]; } diff --git a/MacPass/MPDocument+Search.m b/MacPass/MPDocument+Search.m index ba0da74d..44f46496 100644 --- a/MacPass/MPDocument+Search.m +++ b/MacPass/MPDocument+Search.m @@ -31,6 +31,7 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul - (void)performFindPanelAction:(id)sender { self.hasSearch = YES; [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidEnterSearchNotification object:self]; + [self updateSearch:self]; } - (void)updateSearch:(id)sender { diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index ed928f67..4392a591 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -199,7 +199,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; selector:@selector(_didEnterSearch:) name:MPDocumentDidEnterSearchNotification object:document]; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didExitSearch:) name:MPDocumentDidExitSearchNotification @@ -300,7 +300,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; } } -#pragma mark Notifications +#pragma mark MPDocument Notifications - (void)_didChangeCurrentItem:(NSNotification *)notification { MPDocument *document = [notification object]; @@ -312,9 +312,9 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; If a group is the current item, see if we already show that group */ if(document.selectedItem == document.selectedGroup) { - /* If we change to a group selection, we should clear the filter */ - if(_isDisplayingContextBar) { - // nothing? + if(document.hasSearch) { + /* If search was active, stop it and exit */ + [document exitSearch:self]; } else if([[self.entryArrayController content] count] > 0) { KPKEntry *entry = [[self.entryArrayController content] lastObject]; @@ -336,9 +336,8 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; document.selectedEntry = nil; } } -#pragma mark MPDocumentSearchServiceNotifications + - (void)_didUpdateSearchResults:(NSNotification *)notification { - BOOL main = [NSThread isMainThread]; [self _showContextBar]; NSArray *result = [notification userInfo][kMPDocumentSearchResultsKey]; NSAssert(result != nil, @"Resutls should never be nil"); @@ -348,7 +347,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; [[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:NO]; } -#pragma mark NSDocument+Search Notifications + - (void)_didExitSearch:(NSNotification *)notification { [[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES]; MPDocument *document = [[self windowController] document];