From 52a4242a5238add34d676882ccd5a5b735ca2f8b Mon Sep 17 00:00:00 2001 From: Zaki <18zaki18@gmail.com> Date: Sat, 9 May 2026 22:41:52 +0100 Subject: [PATCH] Auto-focus: loginUsername on load, website in add/edit modals. Enter saves from anywhere inside modals. --- js/app.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index ae5f729..7aaeecc 100644 --- a/js/app.js +++ b/js/app.js @@ -460,6 +460,7 @@ function openAdd() { loadUsername(); populateFolderSelects(); document.getElementById('addModal').classList.add('show'); + document.getElementById('addSite').focus(); playSound('open'); } @@ -1036,6 +1037,7 @@ function openEdit(id) { document.getElementById('editPassword').value = e.password; document.getElementById('editPassword').type = 'password'; document.getElementById('editModal').classList.add('show'); + document.getElementById('editSite').focus(); playSound('open'); } function closeEdit() { document.getElementById('editModal').classList.remove('show'); playSound('close'); } @@ -1376,7 +1378,7 @@ document.addEventListener('mouseup', function(e) { } } }); -document.addEventListener('keydown', e => { if (e.key === 'Enter' && !e.ctrlKey && !e.altKey && !e.metaKey) { const a = document.activeElement; const id = a && a.id; e.preventDefault(); if (id === 'addPassword' || id === 'addSite' || id === 'addUsername') addEntry(); else if (id === 'editPassword' || id === 'editSite' || id === 'editUsername') saveEdit(); else if (id === 'loginPassword') login(); else if (id === 'regPassword') register(); } }); +document.addEventListener('keydown', e => { if (e.key === 'Enter' && !e.ctrlKey && !e.altKey && !e.metaKey) { const a = document.activeElement; if (!a || a.tagName === 'BUTTON') return; e.preventDefault(); if (document.getElementById('editModal').classList.contains('show') && a.closest('.edit-box')) saveEdit(); else if (document.getElementById('addModal').classList.contains('show') && a.closest('.modal-box')) addEntry(); else if (!document.getElementById('authSection').classList.contains('hidden')) { if (a.id === 'loginUsername' || a.id === 'loginPassword') login(); else if (a.id === 'regPassword') register(); } } }); document.getElementById('genModal').addEventListener('click', e => { if (e.target === e.currentTarget) closeGen(); }); document.getElementById('editModal').addEventListener('click', e => { if (e.target === e.currentTarget) closeEdit(); }); // ==================== KEYBOARD SHORTCUTS ==================== @@ -1464,4 +1466,5 @@ document.addEventListener('keydown', function(e) { if (document.getElementById('addModal').classList.contains('show')) addEntry(); else if (document.getElementById('editModal').classList.contains('show')) saveEdit(); } -}); \ No newline at end of file +}); +document.getElementById('loginUsername').focus(); \ No newline at end of file