feat(Popover): add close-on-click-overlay prop (#8351)

This commit is contained in:
neverland
2021-03-15 19:56:53 +08:00
committed by GitHub
parent a835955859
commit a7fb5f732e
4 changed files with 26 additions and 1 deletions
+10 -1
View File
@@ -81,6 +81,10 @@ export default defineComponent({
type: Boolean,
default: true,
},
closeOnClickOverlay: {
type: Boolean,
default: true,
},
},
emits: ['select', 'touchstart', 'update:show'],
@@ -153,7 +157,11 @@ export default defineComponent({
}
};
const onClickAway = () => updateShow(false);
const onClickAway = () => {
if (!props.overlay || props.closeOnClickOverlay) {
updateShow(false);
}
};
const renderAction = (action: PopoverAction, index: number) => {
const { icon, text, color, disabled, className } = action;
@@ -197,6 +205,7 @@ export default defineComponent({
transition="van-popover-zoom"
lockScroll={false}
onTouchstart={onTouchstart}
closeOnClickOverlay={props.closeOnClickOverlay}
{...{ ...attrs, 'onUpdate:show': updateShow }}
>
<div class={bem('arrow')} />