mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 02:16:12 +08:00
[bugfix] AddressList: not trigger select event when click radio icon (#3214)
This commit is contained in:
parent
5889968f29
commit
6fbdc4ffc3
@ -36,6 +36,12 @@ function AddressItem(
|
|||||||
) {
|
) {
|
||||||
const { disabled, switchable } = props;
|
const { disabled, switchable } = props;
|
||||||
|
|
||||||
|
const onSelect = () => {
|
||||||
|
if (props.switchable) {
|
||||||
|
emit(ctx, 'select');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const renderRightIcon = () => (
|
const renderRightIcon = () => (
|
||||||
<Icon
|
<Icon
|
||||||
name="edit"
|
name="edit"
|
||||||
@ -54,13 +60,13 @@ function AddressItem(
|
|||||||
<div class={bem('address')}>{data.address}</div>
|
<div class={bem('address')}>{data.address}</div>
|
||||||
];
|
];
|
||||||
|
|
||||||
return props.switchable ? <Radio name={data.id}>{Info}</Radio> : Info;
|
return props.switchable ? (
|
||||||
};
|
<Radio name={data.id} onClick={onSelect}>
|
||||||
|
{Info}
|
||||||
const onSelect = () => {
|
</Radio>
|
||||||
if (props.switchable) {
|
) : (
|
||||||
emit(ctx, 'select');
|
Info
|
||||||
}
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -26,3 +26,21 @@ test('unswitchable', () => {
|
|||||||
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('select event', () => {
|
||||||
|
const onSelect = jest.fn();
|
||||||
|
const wrapper = mount(AddressList, {
|
||||||
|
propsData: {
|
||||||
|
list
|
||||||
|
},
|
||||||
|
context: {
|
||||||
|
on: {
|
||||||
|
select: onSelect
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
wrapper.find('.van-radio__icon').trigger('click');
|
||||||
|
|
||||||
|
expect(onSelect).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user