This commit is contained in:
Timothy Jaeryang Baek 2025-08-06 23:15:08 +04:00
parent 07aafa5fea
commit e16251c473

View file

@ -136,6 +136,7 @@
const initTags = async () => { const initTags = async () => {
loading = true; loading = true;
await tags.set(await getAllTags(localStorage.token)); await tags.set(await getAllTags(localStorage.token));
loading = false; loading = false;
}; };
@ -144,26 +145,6 @@
value = ''; value = '';
dispatch('input'); dispatch('input');
}; };
const documentClickHandler = (e) => {
const searchContainer = document.getElementById('search-container');
const chatSearch = document.getElementById('chat-search');
if (!searchContainer.contains(e.target) && !chatSearch.contains(e.target)) {
if (e.target.id.startsWith('search-tag-') || e.target.id.startsWith('search-option-')) {
return;
}
focused = false;
}
};
onMount(() => {
document.addEventListener('click', documentClickHandler);
});
onDestroy(() => {
document.removeEventListener('click', documentClickHandler);
});
</script> </script>
<div class="px-1 mb-1 flex justify-center space-x-2 relative z-10" id="search-container"> <div class="px-1 mb-1 flex justify-center space-x-2 relative z-10" id="search-container">
@ -182,6 +163,7 @@
dispatch('input'); dispatch('input');
}} }}
on:focus={() => { on:focus={() => {
hovering = false;
focused = true; focused = true;
initTags(); initTags();
}} }}
@ -258,8 +240,8 @@
selectedIdx = null; selectedIdx = null;
}} }}
on:mouseleave={() => { on:mouseleave={() => {
selectedIdx = 0;
hovering = false; hovering = false;
selectedIdx = 0;
}} }}
> >
<div class="px-2 py-2 text-xs group"> <div class="px-2 py-2 text-xs group">