Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): awaiting noteSwitched not blocking until widgets are done

Elian Dorand947bc41b2bf
diff --git a/apps/client/src/widgets/containers/split_note_container.ts b/apps/client/src/widgets/containers/split_note_container.ts
index e2b755e458..2dd9ea4143 100644
--- a/apps/client/src/widgets/containers/split_note_container.ts
+++ b/apps/client/src/widgets/containers/split_note_container.ts
@@ -250,7 +250,9 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
if (widget.hasBeenAlreadyShown || name === "noteSwitchedAndActivated" || appContext.tabManager.getActiveMainContext() === noteSwitchedContext.noteContext.getMainContext()) {
widget.hasBeenAlreadyShown = true;
- return [widget.handleEvent("noteSwitched", noteSwitchedContext), this.refreshNotShown(noteSwitchedContext)];
+ // Promise.all (not a bare array) so that awaiting triggerEvent("noteSwitched")
+ // genuinely waits for the tab's widgets to process the switch.
+ return Promise.all([ widget.handleEvent("noteSwitched", noteSwitchedContext), this.refreshNotShown(noteSwitchedContext) ]);
}
return Promise.resolve();