Destroy history note OverType instances on task switch
initNoteEditor created OverType instances that were never destroyed when
the user selected a different task. Alpine replaced the DOM nodes but
OverType held internal references. Track instances in _noteEditors and
destroy them before resetting completedTasks.
Assisted-by: Claude Opus 4.6 via Claude Code
diff --git a/public/js/app.js b/public/js/app.js
index 7b1e4bf..a3f9efd 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -93,6 +93,7 @@ document.addEventListener("alpine:init", () => {
addingNoteId: null,
_seriesNoteEditor: null,
_resizeSeriesNote: null,
+ _noteEditors: [],
init() {
const seriesId = sessionStorage.getItem("showSeries")
@@ -114,6 +115,8 @@ document.addEventListener("alpine:init", () => {
this.taskDueDate = el.dataset.taskDueDate
this.taskUrgency = el.dataset.taskUrgency
this.taskOverdue = el.dataset.taskOverdue === "true"
+ this._noteEditors.forEach((e) => e.destroy())
+ this._noteEditors = []
this.completedTasks = []
this.addingNoteId = null
this.editing = false
@@ -173,6 +176,7 @@ document.addEventListener("alpine:init", () => {
padding: "0 4px",
})
+ this._noteEditors.push(editor)
compactOverType(el)
const textarea = el.querySelector("textarea")