diff --git a/bookwyrm/static/js/forms.js b/bookwyrm/static/js/forms.js index 2b25b3c96..a48675b35 100644 --- a/bookwyrm/static/js/forms.js +++ b/bookwyrm/static/js/forms.js @@ -47,11 +47,15 @@ .querySelectorAll("[data-remove]") .forEach((node) => node.addEventListener("click", removeInput)); - document.querySelectorAll("[name='subjects']").forEach((node) => - node.addEventListener("keypress", function (event) { + // Get the element, add a keypress listener... + document.getElementById("subjects").addEventListener("keypress", function (e) { + // e.target is the element where it listens! + // if e.target is input field within the "subjects" div, do stuff + if (e.target && e.target.nodeName == "INPUT") { + // Item found, prevent default if (event.keyCode == 13) { event.preventDefault(); } - }) - ); + } + }); })(); diff --git a/bookwyrm/templates/book/edit/edit_book_form.html b/bookwyrm/templates/book/edit/edit_book_form.html index 728b4819d..e85164444 100644 --- a/bookwyrm/templates/book/edit/edit_book_form.html +++ b/bookwyrm/templates/book/edit/edit_book_form.html @@ -81,7 +81,7 @@ {% include 'snippets/form_errors.html' with errors_list=form.languages.errors id="desc_languages" %} -
+