mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(ImagePreview): should not emit close event after tapped when using async-close (#5410)
This commit is contained in:
parent
3250804791
commit
93e6c81c49
@ -118,12 +118,12 @@ export default createComponent({
|
||||
this.doubleClickTimer = setTimeout(() => {
|
||||
const index = this.active;
|
||||
|
||||
this.$emit('close', {
|
||||
index,
|
||||
url: this.images[index]
|
||||
});
|
||||
|
||||
if (!this.asyncClose) {
|
||||
this.$emit('close', {
|
||||
index,
|
||||
url: this.images[index]
|
||||
});
|
||||
|
||||
this.$emit('input', false);
|
||||
}
|
||||
|
||||
|
@ -36,20 +36,31 @@ test('render image', async () => {
|
||||
expect(wrapper.emitted('change')[0][0]).toEqual(2);
|
||||
});
|
||||
|
||||
test('async close', () => {
|
||||
test('async close prop', async () => {
|
||||
const wrapper = mount(ImagePreviewVue, {
|
||||
propsData: {
|
||||
images,
|
||||
value: true,
|
||||
asyncClose: true
|
||||
},
|
||||
listeners: {
|
||||
input(value) {
|
||||
wrapper.setProps({ value });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const swipe = wrapper.find('.van-swipe__track');
|
||||
|
||||
// should not emit input or close event when tapped
|
||||
triggerDrag(swipe, 0, 0);
|
||||
await later(300);
|
||||
expect(wrapper.emitted('input')).toBeFalsy();
|
||||
expect(wrapper.emitted('close')).toBeFalsy();
|
||||
|
||||
wrapper.vm.close();
|
||||
expect(wrapper.emitted('input')[0][0]).toBeFalsy();
|
||||
expect(wrapper.emitted('input')[0]).toBeTruthy();
|
||||
expect(wrapper.emitted('close')[0]).toBeTruthy();
|
||||
});
|
||||
|
||||
test('function call', done => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user