Skip to content

Commit e63be04

Browse files
authored
fix: Keeps note active even if it's not on the current view when coming from command palette (#2979) [skip e2e]
1 parent bdd78aa commit e63be04

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

packages/web/src/javascripts/Components/CommandPalette/CommandPalette.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function CommandPalette() {
177177
return
178178
}
179179
if (decryptedItem instanceof SNNote) {
180-
void application.navigationController.selectHomeNavigationView()
180+
application.itemListController.keepActiveItemOpenForSystemView(decryptedItem.uuid)
181181
void application.itemListController.selectItemUsingInstance(decryptedItem, true)
182182
} else if (decryptedItem instanceof FileItem) {
183183
void application.filesController.handleFileAction({

packages/web/src/javascripts/Controllers/ItemList/ItemListController.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class ItemListController
8989
includeTrashed: false,
9090
includeProtected: true,
9191
}
92+
private keepActiveItemOpenUuid: UuidString | undefined
9293
webDisplayOptions: WebDisplayOptions = {
9394
hideTags: true,
9495
hideDate: false,
@@ -499,6 +500,10 @@ export class ItemListController
499500
!activeItemExistsInUpdatedResults && !isSearching && this.navigationController.isInAnySystemView()
500501

501502
if (closeBecauseActiveItemDoesntExistInCurrentSystemView) {
503+
if (activeItem && activeItem.uuid === this.keepActiveItemOpenUuid) {
504+
log(LoggingDomain.Selection, 'shouldCloseActiveItem false due to keepActiveItemOpenUuid')
505+
return false
506+
}
502507
log(LoggingDomain.Selection, 'shouldCloseActiveItem closePreviousItemWhenSwitchingToFilesBasedView')
503508
return true
504509
}
@@ -941,6 +946,7 @@ export class ItemListController
941946
}
942947

943948
handleTagChange = async (userTriggered: boolean) => {
949+
this.clearKeepActiveItemOpenUuid()
944950
const activeNoteController = this.getActiveItemController()
945951
if (activeNoteController instanceof NoteViewController && activeNoteController.isTemplateNote) {
946952
this.closeItemController(activeNoteController)
@@ -1196,11 +1202,23 @@ export class ItemListController
11961202
}
11971203
}
11981204

1205+
if (this.keepActiveItemOpenUuid && uuid !== this.keepActiveItemOpenUuid) {
1206+
this.clearKeepActiveItemOpenUuid()
1207+
}
1208+
11991209
return {
12001210
didSelect: this.selectedUuids.has(uuid),
12011211
}
12021212
}
12031213

1214+
keepActiveItemOpenForSystemView = (noteUuid: UuidString): void => {
1215+
this.keepActiveItemOpenUuid = noteUuid
1216+
}
1217+
1218+
private clearKeepActiveItemOpenUuid(): void {
1219+
this.keepActiveItemOpenUuid = undefined
1220+
}
1221+
12041222
selectItem = async (
12051223
uuid: UuidString,
12061224
userTriggered?: boolean,

0 commit comments

Comments
 (0)