From 536721df19640339d6e3a9951ab2e05177a946b6 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 26 Nov 2024 11:44:19 -0800 Subject: [PATCH] tags: Fix issue with JS init on a page without tags - On a page without tags, tags.js still loads and initializes. When a tag input search bar does not exist on the page, this leads to a harmless exception getting printed on the browser console. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- static/tags.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/tags.js b/static/tags.js index 2b293789e..93d83c4c3 100644 --- a/static/tags.js +++ b/static/tags.js @@ -175,7 +175,9 @@ document.addEventListener('DOMContentLoaded', function () { }); const addTagInput = document.getElementById('add-tag-input'); - addTagInput.addEventListener('keyup', onTagInputKeyUp); + if (addTagInput) { // When page loads without tag input element + addTagInput.addEventListener('keyup', onTagInputKeyUp); + } const dropdownItems = document.querySelectorAll('.tag-input li.dropdown-item'); dropdownItems.forEach(item => {