Skip to content

Build your personal knowledge base with Trilium Notes

chore(popup_editor): clean up after closing modal

Elian Doranddbe7e993683
diff --git a/apps/client/src/widgets/dialogs/popup_editor.ts b/apps/client/src/widgets/dialogs/popup_editor.ts
index eb795ffdbc..86c7163285 100644
--- a/apps/client/src/widgets/dialogs/popup_editor.ts
+++ b/apps/client/src/widgets/dialogs/popup_editor.ts
@@ -3,6 +3,7 @@ import NoteContext from "../../components/note_context.js";
import { openDialog } from "../../services/dialog.js";
import BasicWidget from "../basic_widget.js";
import Container from "../containers/container.js";
+import TypeWidget from "../type_widgets/type_widget.js";
const TPL = /*html*/`\
<div class="popup-editor-dialog modal fade mx-auto" tabindex="-1" role="dialog">
@@ -112,6 +113,13 @@ export default class PopupEditorDialog extends Container<BasicWidget> {
this.handleEventInChildren("activeContextChanged", { noteContext: this.noteContext });
});
+ $dialog.on("hidden.bs.modal", () => {
+ const $typeWidgetEl = $dialog.find(".note-detail-printable");
+ if ($typeWidgetEl.length) {
+ const typeWidget = glob.getComponentByEl($typeWidgetEl[0]) as TypeWidget;
+ typeWidget.cleanup();
+ }
+ });
}
handleEventInChildren<T extends EventNames>(name: T, data: EventData<T>): Promise<unknown[] | unknown> | null {
diff --git a/apps/client/src/widgets/type_widgets/empty.ts b/apps/client/src/widgets/type_widgets/empty.ts
index 2f90b5159e..3aed05d5fb 100644
--- a/apps/client/src/widgets/type_widgets/empty.ts
+++ b/apps/client/src/widgets/type_widgets/empty.ts
@@ -3,7 +3,6 @@ import TypeWidget from "./type_widget.js";
import appContext from "../../components/app_context.js";
import searchService from "../../services/search.js";
import { t } from "../../services/i18n.js";
-import type FNote from "../../entities/fnote.js";
const TPL = /*html*/`
<div class="note-detail-empty note-detail-printable">