1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-08-20 21:02:10 +02:00

fix issues with input focus

This commit is contained in:
Morris Brodersen
2020-10-22 14:19:58 +02:00
parent cdffacc69d
commit 9a27e850e1
5 changed files with 37 additions and 10 deletions

View File

@@ -71,6 +71,17 @@ VT.TodoApp = function (el) {
e.detail.placeholder.classList.add('_noflip');
});
// dispatch "focusOther" .use-focus-other inputs if they are not active
// ensures only one edit input is active
el.addEventListener('focusin', function (e) {
if (!e.target.classList.contains('use-focus-other')) return;
document.querySelectorAll('.use-focus-other').forEach(function (el) {
if (el === e.target) return;
el.dispatchEvent(new CustomEvent('focusOther'));
});
});
// listen to the TodoStore's data
// this is the main update
// everything else is related to drag & drop or FLIP animations