mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-10-08 18:00:00 +08:00
[bugfix] Checkbox: label-position prop not work
This commit is contained in:
parent
898ba11483
commit
df275a0168
@ -2,11 +2,19 @@
|
|||||||
|
|
||||||
### [v2.0.0-beta.4](https://github.com/youzan/vant/tree/v2.0.0-beta.4)
|
### [v2.0.0-beta.4](https://github.com/youzan/vant/tree/v2.0.0-beta.4)
|
||||||
|
|
||||||
|
##### Checkbox
|
||||||
|
|
||||||
|
- 修复`label-position`不生效的问题
|
||||||
|
|
||||||
##### Field
|
##### Field
|
||||||
|
|
||||||
- 新增`click`事件
|
- 新增`click`事件
|
||||||
- 新增`clickable`属性
|
- 新增`clickable`属性
|
||||||
|
|
||||||
|
##### Radio
|
||||||
|
|
||||||
|
- 修复`label-position`不生效的问题
|
||||||
|
|
||||||
##### Stepper
|
##### Stepper
|
||||||
|
|
||||||
- 支持`Number`类型的`input-width`属性
|
- 支持`Number`类型的`input-width`属性
|
||||||
|
@ -59,7 +59,6 @@
|
|||||||
line-height: @checkbox-size;
|
line-height: @checkbox-size;
|
||||||
|
|
||||||
&--left {
|
&--left {
|
||||||
float: left;
|
|
||||||
margin: 0 @checkbox-label-margin 0 0;
|
margin: 0 @checkbox-label-margin 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
packages/checkbox/test/__snapshots__/index.spec.js.snap
Normal file
15
packages/checkbox/test/__snapshots__/index.spec.js.snap
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`label disabled 1`] = `
|
||||||
|
<div role="checkbox" tabindex="0" aria-checked="undefined" class="van-checkbox">
|
||||||
|
<div class="van-checkbox__icon van-checkbox__icon--round"><i class="van-icon van-icon-success">
|
||||||
|
<!----></i></div><span class="van-checkbox__label">Label</span>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`label-position prop 1`] = `
|
||||||
|
<div role="checkbox" tabindex="0" aria-checked="undefined" class="van-checkbox"><span class="van-checkbox__label van-checkbox__label--left">Label</span>
|
||||||
|
<div class="van-checkbox__icon van-checkbox__icon--round"><i class="van-icon van-icon-success">
|
||||||
|
<!----></i></div>
|
||||||
|
</div>
|
||||||
|
`;
|
@ -31,8 +31,8 @@ test('disabled', () => {
|
|||||||
|
|
||||||
test('label disabled', () => {
|
test('label disabled', () => {
|
||||||
const wrapper = mount(Checkbox, {
|
const wrapper = mount(Checkbox, {
|
||||||
slots: {
|
scopedSlots: {
|
||||||
default: '<div />'
|
default: () => 'Label'
|
||||||
},
|
},
|
||||||
propsData: {
|
propsData: {
|
||||||
labelDisabled: true
|
labelDisabled: true
|
||||||
@ -41,6 +41,7 @@ test('label disabled', () => {
|
|||||||
|
|
||||||
wrapper.find('.van-checkbox__label').trigger('click');
|
wrapper.find('.van-checkbox__label').trigger('click');
|
||||||
expect(wrapper.emitted('input')).toBeFalsy();
|
expect(wrapper.emitted('input')).toBeFalsy();
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checkbox group', async () => {
|
test('checkbox group', async () => {
|
||||||
@ -91,3 +92,16 @@ test('click event', () => {
|
|||||||
icon.trigger('click');
|
icon.trigger('click');
|
||||||
expect(onClick).toHaveBeenCalledTimes(2);
|
expect(onClick).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('label-position prop', () => {
|
||||||
|
const wrapper = mount(Checkbox, {
|
||||||
|
scopedSlots: {
|
||||||
|
default: () => 'Label'
|
||||||
|
},
|
||||||
|
propsData: {
|
||||||
|
labelPosition: 'left'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
@ -62,6 +62,22 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({
|
|||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const Children = [
|
||||||
|
<div
|
||||||
|
class={bem('icon', [this.shape, { disabled: this.isDisabled, checked }])}
|
||||||
|
style={{ fontSize: suffixPx(this.iconSize) }}
|
||||||
|
onClick={this.onClickIcon}
|
||||||
|
>
|
||||||
|
{CheckIcon}
|
||||||
|
</div>
|
||||||
|
];
|
||||||
|
|
||||||
|
if (this.labelPosition === 'left') {
|
||||||
|
Children.unshift(Label);
|
||||||
|
} else {
|
||||||
|
Children.push(Label);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
role={role}
|
role={role}
|
||||||
@ -72,14 +88,7 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({
|
|||||||
this.$emit('click', event);
|
this.$emit('click', event);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
{Children}
|
||||||
class={bem('icon', [this.shape, { disabled: this.isDisabled, checked }])}
|
|
||||||
style={{ fontSize: suffixPx(this.iconSize) }}
|
|
||||||
onClick={this.onClickIcon}
|
|
||||||
>
|
|
||||||
{CheckIcon}
|
|
||||||
</div>
|
|
||||||
{Label}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,6 @@
|
|||||||
line-height: @radio-size;
|
line-height: @radio-size;
|
||||||
|
|
||||||
&--left {
|
&--left {
|
||||||
float: left;
|
|
||||||
margin: 0 @radio-label-margin 0 0;
|
margin: 0 @radio-label-margin 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user