commit 8e9ee44862a3f7cefc6bc055788997176e3b8af1
parent a7413f4708607c9d139c8831c3ab190d57635a3a
Author: Hunter
Date:   Fri, 23 Aug 2024 01:24:09 -0400

don't move text cursor when defocusing window

Diffstat:
Mindex.html | 15++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/index.html b/index.html @@ -408,8 +408,14 @@ taskInput.addEventListener('keydown', keydownHandler); taskInput.addEventListener('keyup', keyupHandler); taskInput.addEventListener('keydown', handleCopyAndCut); - taskInput.addEventListener('blur', function() { - placeCursorAtBeginning(this); + appContainer.addEventListener('focusin', function(e) { + if (e.target.tagName === 'INPUT' && e.target.type === 'text') { + document.querySelectorAll('input[type="text"]').forEach(input => { + if (input !== e.target) { + placeCursorAtBeginning(input); + } + }); + } }); taskInput.addEventListener('input', () => { @@ -704,11 +710,6 @@ } 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();