diff --git a/js/app.js b/js/app.js index 4a958d5..c811859 100644 --- a/js/app.js +++ b/js/app.js @@ -450,7 +450,7 @@ function renderCard(video, index = 0) {

No results found

Try different keywords or browse by category to find what you're looking for.

- @@ -1025,6 +1025,15 @@ function bindEvents() { // Grid click delegation if (DOM.grid) { DOM.grid.addEventListener('click', (e) => { + const clearEmpty = e.target.closest('#clearSearchEmpty'); + if (clearEmpty) { + if (DOM.search) DOM.search.value = ''; + AppState.search = ''; + if (DOM.clearSearch) DOM.clearSearch.style.display = 'none'; + renderGrid(); + return; + } + const wlBtn = e.target.closest('.watch-later-btn'); if (wlBtn) { e.stopPropagation(); @@ -1159,6 +1168,9 @@ function bindEvents() { // Search focus if (key === '/' && DOM.search) { e.preventDefault(); + if (DOM.searchSection && !DOM.searchSection.classList.contains('active')) { + if (DOM.searchToggle) DOM.searchToggle.click(); + } DOM.search.focus(); } @@ -1167,9 +1179,9 @@ function bindEvents() { closeVideo(); closeWatchLater(); closeDashboard(); - if (DOM.searchToggle && DOM.searchSection && DOM.searchSection.classList.contains('active')) { + if (DOM.searchSection && DOM.searchSection.classList.contains('active')) { DOM.searchSection.classList.remove('active'); - DOM.searchToggle.setAttribute('aria-expanded', 'false'); + if (DOM.searchToggle) DOM.searchToggle.setAttribute('aria-expanded', 'false'); } if (document.body.classList.contains('mobile-nav-active')) { document.body.classList.remove('mobile-nav-active');