Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ function renderCard(video, index = 0) {
<i class="fa-solid fa-magnifying-glass"></i>
<h3>No results found</h3>
<p>Try different keywords or browse by category to find what you're looking for.</p>
<button type="button" class="secondary-button" style="margin-top: 20px;" onclick="document.getElementById('searchInput').value=''; document.getElementById('searchInput').dispatchEvent(new Event('input'));">
<button type="button" id="clearSearchEmpty" class="btn btn-secondary" style="margin-top: 20px;">
Clear Search
</button>
</div>
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

Expand All @@ -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');
Expand Down
Loading