From f1bf8ab9f6947979e2bddad1e2d3324ccce6585c Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Fri, 29 Oct 2021 14:41:27 +0200 Subject: [PATCH] Fixed issue re-selection selected groups when exiting search. This fix is rather ugly but works for now. It should get re-evaluated when the whole selection and search model is being refactored --- MacPass/MPDocument+Search.m | 3 +++ MacPass/MPOutlineViewController.m | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MacPass/MPDocument+Search.m b/MacPass/MPDocument+Search.m index 642ed7fe..7da1e04c 100644 --- a/MacPass/MPDocument+Search.m +++ b/MacPass/MPDocument+Search.m @@ -49,6 +49,9 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul */ [NSNotificationCenter.defaultCenter postNotificationName:MPDocumentDidEnterSearchNotification object:self]; [self updateSearch:self]; + /* clear selection */ + self.selectedGroups = nil; + self.selectedEntries = nil; } #pragma mark Actions diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index dcb9999a..ea6e8465 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -136,7 +136,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; NSInteger visibleRow = [self _rowForUUID:visibleUUID node:node]; selectRow = selectRow > -1 ? selectRow : 1; [self.outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:selectRow] byExtendingSelection:NO]; - + if(visibleRow > -1) { NSRect rowRect = [self.outlineView rectOfRow:visibleRow]; [self.outlineView scrollPoint:rowRect.origin]; @@ -225,7 +225,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; #pragma mark Notifications - (void)registerNotificationsForDocument:(MPDocument *)document { [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didAddGroup:) name:MPDocumentDidAddGroupNotification object:document]; - [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didRevertDocument:) name:MPDocumentDidRevertNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didRevertDocument:) name:MPDocumentDidRevertNotification object:document]; } - (void)clearSelection {