1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-26 10:50:29 +02:00

fix(web): prevent combobox options from disappearing (#7733)

This commit is contained in:
Michel Heusschen 2024-03-12 20:21:42 +01:00 committed by GitHub
parent 17d7d9364f
commit 82aabc63f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,7 @@
export let placeholder = '';
let isOpen = false;
let inputFocused = false;
let searchQuery = selectedOption?.label || '';
$: filteredOptions = options.filter((option) => option.label.toLowerCase().includes(searchQuery.toLowerCase()));
@ -36,11 +37,16 @@
const handleClick = () => {
searchQuery = '';
isOpen = true;
inputFocused = true;
dispatch('click');
};
let handleOutClick = () => {
// In rare cases it's possible for the input to still have focus and
// outclick to fire.
if (!inputFocused) {
isOpen = false;
}
};
let handleSelect = (option: ComboBoxOption) => {
@ -79,6 +85,7 @@
value={isOpen ? '' : selectedOption?.label || ''}
on:input={(e) => (searchQuery = e.currentTarget.value)}
on:focus={handleClick}
on:blur={() => (inputFocused = false)}
/>
<div