mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
fix(popover): fire "click:outside" event when clicking sibling elements (#1570)
This commit is contained in:
parent
fa5515ded0
commit
0f8a57b9d2
6 changed files with 58 additions and 7 deletions
|
@ -1,4 +1,8 @@
|
|||
<script>
|
||||
/**
|
||||
* @event {{ target: HTMLElement; }} click:outside
|
||||
*/
|
||||
|
||||
/** Set to `true` to display the popover */
|
||||
export let open = false;
|
||||
|
||||
|
@ -33,8 +37,8 @@
|
|||
<svelte:window
|
||||
on:click="{(e) => {
|
||||
if (!open) return;
|
||||
if (e.target.contains(ref)) {
|
||||
dispatch('click:outside');
|
||||
if (!ref.contains(e.target)) {
|
||||
dispatch('click:outside', { target: e.target });
|
||||
if (closeOnOutsideClick) open = false;
|
||||
}
|
||||
}}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue