diff --git a/public/js/text.js b/public/js/text.js index 3b2b37e..c15e711 100644 --- a/public/js/text.js +++ b/public/js/text.js @@ -172,7 +172,8 @@ function toggleBulkAddForm(li, parentNodeId, textId) { const saveBtn = document.createElement('button'); saveBtn.textContent = 'Save'; saveBtn.className = 'save-bulk'; - saveBtn.addEventListener('click', () => { + + function submit() { const titlePrefix = titleInput.value.trim(); const count = parseInt(countInput.value); if (!titlePrefix || !count || count < 1) return; @@ -189,9 +190,21 @@ function toggleBulkAddForm(li, parentNodeId, textId) { return res.json(); }) .then(() => fetchAndRenderNodes(textId)); - }); + } + + function submitOnEnter(event) { + if (event.key === 'Enter') { + event.preventDefault(); + submit(); + } + } + + saveBtn.addEventListener('click', submit); + titleInput.addEventListener('keydown', submitOnEnter); + countInput.addEventListener('keydown', submitOnEnter); li.appendChild(titleInput); li.appendChild(countInput); li.appendChild(saveBtn); + titleInput.focus(); }