From 9f6be65ee10f3cfd4ad55b7326e8fb35fc78151a Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 26 Jan 2022 18:44:21 -0800 Subject: [PATCH] Change focus in BrowserUI, never in Model We don't want updates coming in from network sync to move focus around. --- vopamoi.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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) { -- 2.44.1