]> git.scottworley.com Git - vopamoi/commitdiff
Use previous tag name as default new tag name
authorScott Worley <scottworley@scottworley.com>
Thu, 27 Jan 2022 20:10:11 +0000 (12:10 -0800)
committerScott Worley <scottworley@scottworley.com>
Thu, 27 Jan 2022 20:22:18 +0000 (12:22 -0800)
This makes tagging a bunch of tasks with the same tag easier.

vopamoi.ts

index 3b2f1638beb180e3e6b294cfa59b23ee2c73fe3d..a6f85f2dc53864577c98445de5b7606b80eb4ac7 100644 (file)
@@ -215,6 +215,7 @@ enum CommitOrAbort {
 function BrowserUI() {
   var currentViewState = "todo";
   var taskFocusedBeforeJumpingToInput: HTMLElement | null = null;
 function BrowserUI() {
   var currentViewState = "todo";
   var taskFocusedBeforeJumpingToInput: HTMLElement | null = null;
+  var lastTagNameEntered = "";
   return {
     addTask: function (event: KeyboardEvent) {
       const input = <HTMLInputElement>document.getElementById("taskName");
   return {
     addTask: function (event: KeyboardEvent) {
       const input = <HTMLInputElement>document.getElementById("taskName");
@@ -253,8 +254,10 @@ function BrowserUI() {
       const input = document.createElement("input");
       input.classList.add("tag");
       input.addEventListener("blur", this.completeTagEdit, { once: true });
       const input = document.createElement("input");
       input.classList.add("tag");
       input.addEventListener("blur", this.completeTagEdit, { once: true });
+      input.value = lastTagNameEntered;
       task.appendChild(input);
       input.focus();
       task.appendChild(input);
       input.focus();
+      input.select();
       event.preventDefault();
     },
 
       event.preventDefault();
     },
 
@@ -283,6 +286,7 @@ function BrowserUI() {
       task.focus();
       if (!Model.hasTag(task, newTagName)) {
         ui.addTag(task.getAttribute("data-created")!, newTagName);
       task.focus();
       if (!Model.hasTag(task, newTagName)) {
         ui.addTag(task.getAttribute("data-created")!, newTagName);
+        lastTagNameEntered = newTagName;
       }
     },
 
       }
     },