From 598e2f0593a9b5cbc0eb47fe8f32784dadb0e3d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Mon, 18 May 2026 18:10:55 +0200 Subject: [PATCH] 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 --- assets/js/app.js | 7 ++++++- static/js/app.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 9b5bff0..84c8f9a 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -187,7 +187,12 @@ } 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() { diff --git a/static/js/app.js b/static/js/app.js index 9b5bff0..84c8f9a 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -187,7 +187,12 @@ } 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() {