Despite no errors showing up in the Chrome console, the code is functioning properly.
constructor() {
window.onclick = (event: MouseEvent) => {
if (!event.target.matches('.dropbtn')) {
const dropdowns = document.getElementsByClassName('dropdown-content');
let i;
for (i = 0; i < dropdowns.length; i++) {
const openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
};
}
It seems to be related to TypeScript. Has anyone encountered this issue before?