mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 12:15:47 -04:00
fix(web): prevent combobox options from disappearing (#7733)
This commit is contained in:
parent
17d7d9364f
commit
82aabc63f5
@ -24,6 +24,7 @@
|
|||||||
export let placeholder = '';
|
export let placeholder = '';
|
||||||
|
|
||||||
let isOpen = false;
|
let isOpen = false;
|
||||||
|
let inputFocused = false;
|
||||||
let searchQuery = selectedOption?.label || '';
|
let searchQuery = selectedOption?.label || '';
|
||||||
|
|
||||||
$: filteredOptions = options.filter((option) => option.label.toLowerCase().includes(searchQuery.toLowerCase()));
|
$: filteredOptions = options.filter((option) => option.label.toLowerCase().includes(searchQuery.toLowerCase()));
|
||||||
@ -36,11 +37,16 @@
|
|||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
searchQuery = '';
|
searchQuery = '';
|
||||||
isOpen = true;
|
isOpen = true;
|
||||||
|
inputFocused = true;
|
||||||
dispatch('click');
|
dispatch('click');
|
||||||
};
|
};
|
||||||
|
|
||||||
let handleOutClick = () => {
|
let handleOutClick = () => {
|
||||||
|
// In rare cases it's possible for the input to still have focus and
|
||||||
|
// outclick to fire.
|
||||||
|
if (!inputFocused) {
|
||||||
isOpen = false;
|
isOpen = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let handleSelect = (option: ComboBoxOption) => {
|
let handleSelect = (option: ComboBoxOption) => {
|
||||||
@ -79,6 +85,7 @@
|
|||||||
value={isOpen ? '' : selectedOption?.label || ''}
|
value={isOpen ? '' : selectedOption?.label || ''}
|
||||||
on:input={(e) => (searchQuery = e.currentTarget.value)}
|
on:input={(e) => (searchQuery = e.currentTarget.value)}
|
||||||
on:focus={handleClick}
|
on:focus={handleClick}
|
||||||
|
on:blur={() => (inputFocused = false)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
Loading…
x
Reference in New Issue
Block a user