mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Popover): add click-overlay event (#8050)
This commit is contained in:
parent
d27626ada2
commit
63227201ff
@ -227,13 +227,14 @@ export default {
|
|||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
| Event | Description | Arguments |
|
| Event | Description | Arguments |
|
||||||
| ------ | --------------------------------- | ------------------------------- |
|
| --- | --- | --- |
|
||||||
| select | Emitted when an action is clicked | _action: Action, index: number_ |
|
| select | Emitted when an action is clicked | _action: Action, index: number_ |
|
||||||
| open | Emitted when opening Popover | - |
|
| open | Emitted when opening Popover | - |
|
||||||
| close | Emitted when closing Popover | - |
|
| close | Emitted when closing Popover | - |
|
||||||
| opened | Emitted when Popover is opened | - |
|
| opened | Emitted when Popover is opened | - |
|
||||||
| closed | Emitted when Popover is closed | - |
|
| closed | Emitted when Popover is closed | - |
|
||||||
|
| click-overlay | Emitted when overlay is clicked | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -243,13 +243,14 @@ export default {
|
|||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
| 事件名 | 说明 | 回调参数 |
|
| 事件名 | 说明 | 回调参数 |
|
||||||
| ------ | ------------------------ | ------------------------------- |
|
| ------------- | ------------------------ | ------------------------------- |
|
||||||
| select | 点击选项时触发 | _action: Action, index: number_ |
|
| select | 点击选项时触发 | _action: Action, index: number_ |
|
||||||
| open | 打开菜单时触发 | - |
|
| open | 打开菜单时触发 | - |
|
||||||
| close | 关闭菜单时触发 | - |
|
| close | 关闭菜单时触发 | - |
|
||||||
| opened | 打开菜单且动画结束后触发 | - |
|
| opened | 打开菜单且动画结束后触发 | - |
|
||||||
| closed | 关闭菜单且动画结束后触发 | - |
|
| closed | 关闭菜单且动画结束后触发 | - |
|
||||||
|
| click-overlay | 点击遮罩层时触发 | - |
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
v-model:show="show.lightTheme"
|
v-model:show="show.lightTheme"
|
||||||
:actions="t('actions')"
|
:actions="t('actions')"
|
||||||
placement="bottom-start"
|
placement="bottom-start"
|
||||||
class="foo"
|
|
||||||
@select="onSelect"
|
@select="onSelect"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
|
@ -148,3 +148,18 @@ test('should close popover when touch outside content', async () => {
|
|||||||
trigger(document.body, 'touchstart');
|
trigger(document.body, 'touchstart');
|
||||||
expect(wrapper.emitted('update:show')[0][0]).toEqual(false);
|
expect(wrapper.emitted('update:show')[0][0]).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should emit click-overlay event when overlay is clicked', () => {
|
||||||
|
const onClickOverlay = jest.fn();
|
||||||
|
const wrapper = mount(Popover, {
|
||||||
|
props: {
|
||||||
|
show: true,
|
||||||
|
overlay: true,
|
||||||
|
teleport: null,
|
||||||
|
onClickOverlay,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
wrapper.find('.van-overlay').trigger('click');
|
||||||
|
expect(onClickOverlay).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user