mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +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 onSelect = () => {
|
||||
if (props.switchable) {
|
||||
emit(ctx, 'select');
|
||||
}
|
||||
};
|
||||
|
||||
const renderRightIcon = () => (
|
||||
<Icon
|
||||
name="edit"
|
||||
@ -54,13 +60,13 @@ function AddressItem(
|
||||
<div class={bem('address')}>{data.address}</div>
|
||||
];
|
||||
|
||||
return props.switchable ? <Radio name={data.id}>{Info}</Radio> : Info;
|
||||
};
|
||||
|
||||
const onSelect = () => {
|
||||
if (props.switchable) {
|
||||
emit(ctx, 'select');
|
||||
}
|
||||
return props.switchable ? (
|
||||
<Radio name={data.id} onClick={onSelect}>
|
||||
{Info}
|
||||
</Radio>
|
||||
) : (
|
||||
Info
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -26,3 +26,21 @@ test('unswitchable', () => {
|
||||
|
||||
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