diff --git a/MacPass/MPDocument+HistoryBrowsing.m b/MacPass/MPDocument+HistoryBrowsing.m index 97a3e64d..5357b94d 100644 --- a/MacPass/MPDocument+HistoryBrowsing.m +++ b/MacPass/MPDocument+HistoryBrowsing.m @@ -19,11 +19,17 @@ NSString *const MPDocumentHideEntryHistoryNotification = @"MPDocumentHideEntryH if(entries.count != 1) { return; // only single selection is used } - [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentShowEntryHistoryNotification object:self userInfo:@{ MPDocumentEntryKey: entries.firstObject }]; + if(self.hasSearch) { + [self exitSearch:sender]; + } + [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentShowEntryHistoryNotification + object:self + userInfo:@{ MPDocumentEntryKey: entries.firstObject }]; } - (void)hideEntryHistory:(id)sender { - [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentHideEntryHistoryNotification object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentHideEntryHistoryNotification + object:self]; } diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 6cd61b7c..c09fa089 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -459,7 +459,6 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; NSArray *result = notification.userInfo[kMPDocumentSearchResultsKey]; NSAssert(result != nil, @"Resutls should never be nil"); self.filteredEntries = result; - [self.entryArrayController unbind:NSContentArrayBinding]; [self.entryArrayController bind:NSContentArrayBinding toObject:self withKeyPath:NSStringFromSelector(@selector(filteredEntries)) options:nil]; [self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier].hidden = NO; [self _updateContextBar]; @@ -468,9 +467,13 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; - (void)_didExitSearch:(NSNotification *)notification { [self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier].hidden = YES; + [self.entryArrayController unbind:NSContentArrayBinding]; + self.entryArrayController.content = nil; self.filteredEntries = nil; self.displayMode = MPDisplayModeEntries; [self _updateContextBar]; + MPDocument *document = notification.object; + document.selectedGroups = document.selectedGroups; } - (void)_didEnterSearch:(NSNotification *)notification { @@ -493,14 +496,17 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; self.displayMode = MPDisplayModeHistory; KPKEntry *entry = notification.userInfo[MPDocumentEntryKey]; NSAssert(entry != nil, @"Resutls should never be nil"); - [self.entryArrayController unbind:NSContentArrayBinding]; [self.entryArrayController bind:NSContentArrayBinding toObject:entry withKeyPath:NSStringFromSelector(@selector(history)) options:nil]; [self _updateContextBar]; } - (void)_hideEntryHistory:(NSNotification *)notification { self.displayMode = MPDisplayModeEntries; + [self.entryArrayController unbind:NSContentArrayBinding]; + self.entryArrayController.content = nil; [self _updateContextBar]; + MPDocument *document = notification.object; + document.selectedGroups = document.selectedGroups; } #pragma mark ContextBar - (void)_updateContextBar {