mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Popover): close-on-click-outside not work (#8352)
This commit is contained in:
parent
d9c51b9070
commit
40a1b27c5d
@ -85,6 +85,10 @@ export default defineComponent({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
closeOnClickOutside: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['select', 'touchstart', 'update:show'],
|
emits: ['select', 'touchstart', 'update:show'],
|
||||||
@ -158,7 +162,10 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onClickAway = () => {
|
const onClickAway = () => {
|
||||||
if (!props.overlay || props.closeOnClickOverlay) {
|
if (
|
||||||
|
props.closeOnClickOutside &&
|
||||||
|
(!props.overlay || props.closeOnClickOverlay)
|
||||||
|
) {
|
||||||
updateShow(false);
|
updateShow(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -175,3 +175,15 @@ test('should not close Popover when overlay is clicked and close-on-click-overla
|
|||||||
trigger(overlay, 'touchstart');
|
trigger(overlay, 'touchstart');
|
||||||
expect(wrapper.emitted('update:show')).toBeFalsy();
|
expect(wrapper.emitted('update:show')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not close Popover when outside is clicked and close-on-click-outside is false', () => {
|
||||||
|
const wrapper = mount(Popover, {
|
||||||
|
props: {
|
||||||
|
show: true,
|
||||||
|
closeOnClickOutside: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
trigger(document.body, 'touchstart');
|
||||||
|
expect(wrapper.emitted('update:show')).toBeFalsy();
|
||||||
|
});
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import {isDef} from "./base";
|
import { isDef } from './base';
|
||||||
|
|
||||||
export function deepClone<T extends Record<string, any> | null | undefined>(obj: T): T {
|
export function deepClone<T extends Record<string, any> | null | undefined>(
|
||||||
|
obj: T
|
||||||
|
): T {
|
||||||
if (!isDef(obj)) {
|
if (!isDef(obj)) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user