mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 23:19:15 +08:00
fix(ActionSheet): should not reopen when closed (#8272)
This commit is contained in:
parent
059ed39135
commit
d4fda0b4b0
@ -1,4 +1,4 @@
|
|||||||
import { PropType } from 'vue';
|
import { nextTick, PropType } from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { createNamespace, pick } from '../utils';
|
import { createNamespace, pick } from '../utils';
|
||||||
@ -115,11 +115,11 @@ export default createComponent({
|
|||||||
callback(item);
|
callback(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit('select', item, index);
|
|
||||||
|
|
||||||
if (props.closeOnClickAction) {
|
if (props.closeOnClickAction) {
|
||||||
updateShow(false);
|
updateShow(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nextTick(() => emit('select', item, index));
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import { nextTick } from 'vue';
|
||||||
import { mount } from '../../../test';
|
import { mount } from '../../../test';
|
||||||
import ActionSheet from '..';
|
import ActionSheet from '..';
|
||||||
|
|
||||||
test('should emit select event after clicking option', () => {
|
test('should emit select event after clicking option', async () => {
|
||||||
const wrapper = mount(ActionSheet, {
|
const wrapper = mount(ActionSheet, {
|
||||||
props: {
|
props: {
|
||||||
show: true,
|
show: true,
|
||||||
@ -10,6 +11,8 @@ test('should emit select event after clicking option', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
wrapper.find('.van-action-sheet__item').trigger('click');
|
wrapper.find('.van-action-sheet__item').trigger('click');
|
||||||
|
|
||||||
|
await nextTick();
|
||||||
expect(wrapper.emitted('select')!.length).toEqual(1);
|
expect(wrapper.emitted('select')!.length).toEqual(1);
|
||||||
expect(wrapper.emitted('select')![0]).toEqual([
|
expect(wrapper.emitted('select')![0]).toEqual([
|
||||||
{
|
{
|
||||||
@ -32,7 +35,7 @@ test('should call callback function after clicking option', () => {
|
|||||||
expect(callback).toHaveBeenCalledTimes(1);
|
expect(callback).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not emit select event after clicking loading option', () => {
|
test('should not emit select event after clicking loading option', async () => {
|
||||||
const wrapper = mount(ActionSheet, {
|
const wrapper = mount(ActionSheet, {
|
||||||
props: {
|
props: {
|
||||||
show: true,
|
show: true,
|
||||||
@ -41,10 +44,11 @@ test('should not emit select event after clicking loading option', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
wrapper.find('.van-action-sheet__item').trigger('click');
|
wrapper.find('.van-action-sheet__item').trigger('click');
|
||||||
|
await nextTick();
|
||||||
expect(wrapper.emitted('select')).toBeFalsy();
|
expect(wrapper.emitted('select')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not emit select event after clicking disabled option', () => {
|
test('should not emit select event after clicking disabled option', async () => {
|
||||||
const wrapper = mount(ActionSheet, {
|
const wrapper = mount(ActionSheet, {
|
||||||
props: {
|
props: {
|
||||||
show: true,
|
show: true,
|
||||||
@ -53,6 +57,7 @@ test('should not emit select event after clicking disabled option', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
wrapper.find('.van-action-sheet__item').trigger('click');
|
wrapper.find('.van-action-sheet__item').trigger('click');
|
||||||
|
await nextTick();
|
||||||
expect(wrapper.emitted('select')).toBeFalsy();
|
expect(wrapper.emitted('select')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user