Fix Input Dropdown Outside Click (#8404)

This commit is contained in:
Gerard Burns 2022-10-26 13:48:48 +01:00 committed by GitHub
parent 50f0a0509d
commit 9e5d39e3ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -102,6 +102,13 @@
} }
return value return value
} }
const handleOutsideClick = event => {
if (open) {
event.stopPropagation()
open = false
}
}
</script> </script>
<div <div
@ -151,7 +158,7 @@
{disabled} {disabled}
class:is-open={open} class:is-open={open}
aria-haspopup="listbox" aria-haspopup="listbox"
on:mousedown={onClick} on:click={onClick}
> >
<span class="spectrum-Picker-label"> <span class="spectrum-Picker-label">
<div> <div>
@ -168,7 +175,7 @@
</button> </button>
{#if open} {#if open}
<div <div
use:clickOutside={() => (open = false)} use:clickOutside={handleOutsideClick}
transition:fly|local={{ y: -20, duration: 200 }} transition:fly|local={{ y: -20, duration: 200 }}
class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
> >