]> git.scottworley.com Git - vopamoi/blobdiff - vopamoi.ts
Use previous tag name as default new tag name
[vopamoi] / vopamoi.ts
index 3b2f1638beb180e3e6b294cfa59b23ee2c73fe3d..a6f85f2dc53864577c98445de5b7606b80eb4ac7 100644 (file)
@@ -215,6 +215,7 @@ enum CommitOrAbort {
 function BrowserUI() {
   var currentViewState = "todo";
   var taskFocusedBeforeJumpingToInput: HTMLElement | null = null;
+  var lastTagNameEntered = "";
   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 });
+      input.value = lastTagNameEntered;
       task.appendChild(input);
       input.focus();
+      input.select();
       event.preventDefault();
     },
 
@@ -283,6 +286,7 @@ function BrowserUI() {
       task.focus();
       if (!Model.hasTag(task, newTagName)) {
         ui.addTag(task.getAttribute("data-created")!, newTagName);
+        lastTagNameEntered = newTagName;
       }
     },