diff --git a/web/src/lib/components/elements/dropdown.svelte b/web/src/lib/components/elements/dropdown.svelte index 6bf9b55d65..b69b191f25 100644 --- a/web/src/lib/components/elements/dropdown.svelte +++ b/web/src/lib/components/elements/dropdown.svelte @@ -15,8 +15,12 @@ import { fly } from 'svelte/transition'; import { createEventDispatcher } from 'svelte'; + let className = ''; + export { className as class }; + const dispatch = createEventDispatcher<{ select: T; + 'click-outside': void; }>(); export let options: T[]; @@ -36,6 +40,8 @@ if (!controlable) { showMenu = false; } + + dispatch('click-outside'); }; const handleSelectOption = (option: T) => { @@ -76,7 +82,7 @@ {#if showMenu}
{#each options as option (option)} {@const renderedOption = renderOption(option)} diff --git a/web/src/lib/components/shared-components/change-date.svelte b/web/src/lib/components/shared-components/change-date.svelte index ee350f7b12..d9cd810c3e 100644 --- a/web/src/lib/components/shared-components/change-date.svelte +++ b/web/src/lib/components/shared-components/change-date.svelte @@ -59,12 +59,27 @@ dispatch('confirm', value); } }; + const handleKeydown = (event: KeyboardEvent) => { if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) { event.stopPropagation(); } }; + let isDropdownOpen = false; + let isSearching = false; + + const onSearchFocused = () => { + isSearching = true; + + openDropdown(); + }; + + const onSearchBlurred = () => { + isSearching = false; + + closeDropdown(); + }; const openDropdown = () => { isDropdownOpen = true; @@ -84,42 +99,46 @@ -
+
-
+
+
(item ? `${item.zone} (${item.offset})` : '(not selected)')} on:select={({ detail: item }) => handleSelectTz(item)} controlable={true} bind:showMenu={isDropdownOpen} + on:click-outside={isSearching ? null : closeDropdown} />
diff --git a/web/src/lib/components/shared-components/confirm-dialogue.svelte b/web/src/lib/components/shared-components/confirm-dialogue.svelte index ae4bd24a4f..1457e469b1 100644 --- a/web/src/lib/components/shared-components/confirm-dialogue.svelte +++ b/web/src/lib/components/shared-components/confirm-dialogue.svelte @@ -13,7 +13,7 @@ export let hideCancelButton = false; export let disabled = false; - const dispatch = createEventDispatcher<{ cancel: void; confirm: void }>(); + const dispatch = createEventDispatcher<{ cancel: void; confirm: void; 'click-outside': void }>(); let isConfirmButtonDisabled = false; @@ -28,9 +28,13 @@ isConfirmButtonDisabled = true; dispatch('confirm'); }; + + const handleClickOutside = () => { + dispatch('click-outside'); + }; - handleEscape()}> + handleEscape()}>