From: Scott Worley Date: Thu, 27 Jan 2022 02:44:21 +0000 (-0800) Subject: Change focus in BrowserUI, never in Model X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/9f6be65ee10f3cfd4ad55b7326e8fb35fc78151a?ds=sidebyside Change focus in BrowserUI, never in Model We don't want updates coming in from network sync to move focus around. --- diff --git a/vopamoi.ts b/vopamoi.ts index 298e513..a98a29b 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -21,7 +21,6 @@ const Model = { task.setAttribute("tabindex", "0"); task.setAttribute("data-created", timestamp); document.getElementById("tasks")!.appendChild(task); - task.focus(); return task; }, @@ -51,12 +50,10 @@ const Model = { for (const task of document.getElementsByClassName("task")) { if (task !== target && this.getPriority(task) > priority) { task.parentElement!.insertBefore(target, task); - target instanceof HTMLElement && target.focus(); return target; } } document.getElementById("tasks")!.appendChild(target); - target instanceof HTMLElement && target.focus(); return target; }, @@ -140,6 +137,7 @@ const BrowserUI = { const input = document.getElementById("taskName"); if (input.value) { const task = UI.addTask(input.value); + if (task && task instanceof HTMLElement) task.focus(); input.value = ""; if (event.getModifierState("Control")) { this.setPriority(task, null, document.getElementsByClassName("task")[0]); @@ -212,6 +210,7 @@ const BrowserUI = { const newPriorityRounded = Math.round(newPriority); const okToRound = aPriority < newPriorityRounded && newPriorityRounded < bPriority; UI.setPriority(task.getAttribute("data-created")!, okToRound ? newPriorityRounded : newPriority, Model.getPriority(task)); + task instanceof HTMLElement && task.focus(); }, setState: function (state: string) {