Skip to content

Commit 2147dde

Browse files
committed
Reset search when clicking sidebar items
- Clear search input when sidebar snippet item is clicked - Ensures all snippets are visible before navigation - Fixes issue where non-matching sidebar items weren't shown during search - Adds small delay to allow search reset to complete before scrolling
1 parent 4a346c7 commit 2147dde

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

public/js/app.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,13 @@ document.addEventListener('DOMContentLoaded', () => {
296296
e.target.classList.toggle('open');
297297
} else if (e.target.classList.contains('snippet-item')) {
298298
const snippetId = e.target.dataset.snippetId;
299-
ensureSnippetLoadedAndScroll(snippetId);
299+
// Reset search when clicking on sidebar item to show all snippets
300+
searchInput.value = '';
301+
searchInput.dispatchEvent(new Event('input'));
302+
// Small delay to allow search reset to complete before scrolling
303+
setTimeout(() => {
304+
ensureSnippetLoadedAndScroll(snippetId);
305+
}, 50);
300306
}
301307
});
302308

0 commit comments

Comments
 (0)