mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 19:46:36 +00:00
feat(popover): add closeOnOutsideClick prop
This commit is contained in:
parent
4397d852eb
commit
b728454a60
6 changed files with 81 additions and 12 deletions
|
@ -6800,6 +6800,16 @@
|
|||
"value": "false",
|
||||
"isFunction": false,
|
||||
"constant": false,
|
||||
"reactive": true
|
||||
},
|
||||
{
|
||||
"name": "closeOnOutsideClick",
|
||||
"kind": "let",
|
||||
"description": "Set to `true` to close the popover on an outside click",
|
||||
"type": "boolean",
|
||||
"value": "false",
|
||||
"isFunction": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
|
@ -6854,7 +6864,7 @@
|
|||
}
|
||||
],
|
||||
"slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }],
|
||||
"events": [],
|
||||
"events": [{ "type": "dispatched", "name": "click:outside" }],
|
||||
"typedefs": [],
|
||||
"rest_props": { "type": "Element", "name": "div" }
|
||||
},
|
||||
|
|
|
@ -14,7 +14,7 @@ By default, the position of the popover component is absolute.
|
|||
</Popover>
|
||||
</div>
|
||||
|
||||
### Relative
|
||||
### Relative position
|
||||
|
||||
Set `relative` to `true` to use a relative position.
|
||||
|
||||
|
@ -25,6 +25,16 @@ Set `relative` to `true` to use a relative position.
|
|||
</Popover>
|
||||
</div>
|
||||
|
||||
### Close on outside click
|
||||
|
||||
Set `closeOnOutsideClick` to set `open` to `false` when clicking outside of the popover.
|
||||
|
||||
<div data-outline="relative">
|
||||
Parent
|
||||
<Popover open closeOnOutsideClick on:click:outside={() => {console.log('on:click:outside')}}>
|
||||
<div style="padding: var(--cds-spacing-05)">Content</div>
|
||||
</Popover>
|
||||
</div>
|
||||
|
||||
### With caret
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue