Fix search input losing focus on mouse click
The click-outside handler was checking for .subhead (a BEM class removed in the Tailwind refactor) so every click including on the input itself triggered closeSearch(). Now checks for the actual search label and popup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-1
@@ -187,7 +187,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('click', e => {
|
document.addEventListener('click', e => {
|
||||||
if (searchPop && searchPop.dataset.open === 'true' && !e.target.closest('.subhead')) closeSearch();
|
if (searchPop && searchPop.dataset.open === 'true') {
|
||||||
|
const inSearch = e.target.closest('label[for="searchInput"]')
|
||||||
|
|| e.target.id === 'searchInput'
|
||||||
|
|| e.target.closest('#searchpop');
|
||||||
|
if (!inSearch) closeSearch();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function closeSearch() {
|
function closeSearch() {
|
||||||
|
|||||||
+6
-1
@@ -187,7 +187,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('click', e => {
|
document.addEventListener('click', e => {
|
||||||
if (searchPop && searchPop.dataset.open === 'true' && !e.target.closest('.subhead')) closeSearch();
|
if (searchPop && searchPop.dataset.open === 'true') {
|
||||||
|
const inSearch = e.target.closest('label[for="searchInput"]')
|
||||||
|
|| e.target.id === 'searchInput'
|
||||||
|
|| e.target.closest('#searchpop');
|
||||||
|
if (!inSearch) closeSearch();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function closeSearch() {
|
function closeSearch() {
|
||||||
|
|||||||
Reference in New Issue
Block a user