fix: Keeps note active even if it's not on the current view when coming from command palette (#2979) [skip e2e]

This commit is contained in:
Antonella Sgarlatta
2026-02-05 11:23:19 -03:00
committed by GitHub
parent bdd78aade3
commit e63be048f4
2 changed files with 19 additions and 1 deletions

View File

@@ -177,7 +177,7 @@ function CommandPalette() {
return
}
if (decryptedItem instanceof SNNote) {
void application.navigationController.selectHomeNavigationView()
application.itemListController.keepActiveItemOpenForSystemView(decryptedItem.uuid)
void application.itemListController.selectItemUsingInstance(decryptedItem, true)
} else if (decryptedItem instanceof FileItem) {
void application.filesController.handleFileAction({

View File

@@ -89,6 +89,7 @@ export class ItemListController
includeTrashed: false,
includeProtected: true,
}
private keepActiveItemOpenUuid: UuidString | undefined
webDisplayOptions: WebDisplayOptions = {
hideTags: true,
hideDate: false,
@@ -499,6 +500,10 @@ export class ItemListController
!activeItemExistsInUpdatedResults && !isSearching && this.navigationController.isInAnySystemView()
if (closeBecauseActiveItemDoesntExistInCurrentSystemView) {
if (activeItem && activeItem.uuid === this.keepActiveItemOpenUuid) {
log(LoggingDomain.Selection, 'shouldCloseActiveItem false due to keepActiveItemOpenUuid')
return false
}
log(LoggingDomain.Selection, 'shouldCloseActiveItem closePreviousItemWhenSwitchingToFilesBasedView')
return true
}
@@ -941,6 +946,7 @@ export class ItemListController
}
handleTagChange = async (userTriggered: boolean) => {
this.clearKeepActiveItemOpenUuid()
const activeNoteController = this.getActiveItemController()
if (activeNoteController instanceof NoteViewController && activeNoteController.isTemplateNote) {
this.closeItemController(activeNoteController)
@@ -1196,11 +1202,23 @@ export class ItemListController
}
}
if (this.keepActiveItemOpenUuid && uuid !== this.keepActiveItemOpenUuid) {
this.clearKeepActiveItemOpenUuid()
}
return {
didSelect: this.selectedUuids.has(uuid),
}
}
keepActiveItemOpenForSystemView = (noteUuid: UuidString): void => {
this.keepActiveItemOpenUuid = noteUuid
}
private clearKeepActiveItemOpenUuid(): void {
this.keepActiveItemOpenUuid = undefined
}
selectItem = async (
uuid: UuidString,
userTriggered?: boolean,