commit e7cb0c339023be58466444fbea2d2e83a15f1001
parent 79e288d19320d66458d6f1af1b36e84b52284078
Author: Hunter
Date: Sun, 11 Aug 2024 15:59:56 -0400
move cursor to start of input when task is blurred
Diffstat:
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/index.html b/index.html
@@ -411,6 +411,9 @@
taskInput.addEventListener('keydown', keydownHandler);
taskInput.addEventListener('keyup', keyupHandler);
taskInput.addEventListener('keydown', handleCopyAndCut);
+ taskInput.addEventListener('blur', function() {
+ placeCursorAtBeginning(this);
+ });
taskInput.addEventListener('input', () => {
task.text = taskInput.value;
@@ -704,6 +707,11 @@
}
function selectAndFocusTask(task) {
+ const activeInput = document.querySelector('.task-container.active input[type="text"]');
+ if (activeInput) {
+ placeCursorAtBeginning(activeInput);
+ }
+
const taskInput = document.querySelector(`.task-container[data-id="${task.id}"] input[type="text"]`);
if (taskInput) {
taskInput.focus();
@@ -712,8 +720,8 @@
}
}
- function placeCursorAtBeginning(taskInput) {
- taskInput.setSelectionRange(0, 0);
+ function placeCursorAtBeginning(input) {
+ input.setSelectionRange(0, 0);
}
function navigateTasks(direction) {
@@ -725,12 +733,10 @@
if (direction === 'up') {
if (currentIndex > 0) {
const prevTask = currentIndex === 1 ? currentTask : tasks[currentIndex - 2];
- placeCursorAtBeginning(currentElement);
selectAndFocusTask(prevTask);
}
} else {
if (currentIndex < tasks.length) {
- placeCursorAtBeginning(currentElement);
selectAndFocusTask(tasks[currentIndex]);
}
}
diff --git a/readme.md b/readme.md
@@ -5,7 +5,7 @@ a nested task manager that breaks complex tasks into manageable subtasks.
<a href="https://hunterirving.github.io/matryoshka/"><img src="screenshot.gif" width="560px"></a><br>
<b><i>try it now <a href="https://hunterirving.github.io/matryoshka/">in your browser</a> !</i></b>
-<br>(physical keyboard required (for now))
+<br>(physical keyboard required for now)
### key features
- unlimited subtask depth