return {
addTask: function (event: KeyboardEvent) {
const input = <HTMLInputElement>document.getElementById("taskName");
- if (input.value) {
- const task = ui.addTask(input.value);
- if (currentViewState === "todo") {
- task instanceof HTMLElement && task.focus();
- } else if (this.returnFocusAfterInput()) {
- } else {
- this.firstVisibleTask()?.focus();
- }
- input.value = "";
- if (event.getModifierState("Control")) {
- this.setPriority(task, null, document.getElementsByClassName("task")[0]);
- }
+ if (input.value.match(/^ *$/)) return;
+ const task = ui.addTask(input.value);
+ if (currentViewState === "todo") {
+ task instanceof HTMLElement && task.focus();
+ } else if (this.returnFocusAfterInput()) {
+ } else {
+ this.firstVisibleTask()?.focus();
+ }
+ input.value = "";
+ if (event.getModifierState("Control")) {
+ this.setPriority(task, null, document.getElementsByClassName("task")[0]);
}
},
task.removeChild(input);
task.removeAttribute("data-description");
task.focus();
- if (newDescription === oldDescription || resolution === CommitOrAbort.Abort) {
+ if (resolution === CommitOrAbort.Abort || newDescription.match(/^ *$/) || newDescription === oldDescription) {
desc.textContent = oldDescription;
} else {
ui.edit(task.getAttribute("data-created")!, newDescription, oldDescription);
input.removeEventListener("blur", this.completeTagEdit);
task.removeChild(input);
task.focus();
- if (resolution === CommitOrAbort.Commit && newTagName && !Model.hasTag(task, newTagName)) {
+ if (resolution === CommitOrAbort.Commit && !newTagName.match(/^ *$/) && !Model.hasTag(task, newTagName)) {
ui.addTag(task.getAttribute("data-created")!, newTagName);
lastTagNameEntered = newTagName;
}