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 <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2024-11-26 11:44:19 -08:00 committed by Veiko Aasa
parent 4705a86f90
commit 536721df19
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -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 => {