mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 02:16:12 +08:00
[bugfix] Radio: can't select when click gap (#4007)
This commit is contained in:
parent
cabd3c0f14
commit
4d8c4df5fe
@ -45,18 +45,6 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onClickIcon() {
|
|
||||||
if (!this.isDisabled) {
|
|
||||||
this.toggle();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onClickLabel() {
|
|
||||||
if (!this.isDisabled && !this.labelDisabled) {
|
|
||||||
this.toggle();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setParentValue(val) {
|
setParentValue(val) {
|
||||||
const { parent } = this;
|
const { parent } = this;
|
||||||
const value = parent.value.slice();
|
const value = parent.value.slice();
|
||||||
|
@ -46,6 +46,20 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onClick(event) {
|
||||||
|
const { label } = this.$refs;
|
||||||
|
const { target } = event;
|
||||||
|
const labelClicked = label && (label === target || label.contains(target));
|
||||||
|
|
||||||
|
if (!this.disabled && !(labelClicked && this.labelDisabled)) {
|
||||||
|
this.toggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$emit('click', event);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { slots, checked } = this;
|
const { slots, checked } = this;
|
||||||
|
|
||||||
@ -55,8 +69,8 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({
|
|||||||
|
|
||||||
const Label = slots() && (
|
const Label = slots() && (
|
||||||
<span
|
<span
|
||||||
|
ref="label"
|
||||||
class={bem('label', [this.labelPosition, { disabled: this.isDisabled }])}
|
class={bem('label', [this.labelPosition, { disabled: this.isDisabled }])}
|
||||||
onClick={this.onClickLabel}
|
|
||||||
>
|
>
|
||||||
{slots()}
|
{slots()}
|
||||||
</span>
|
</span>
|
||||||
@ -66,7 +80,6 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({
|
|||||||
<div
|
<div
|
||||||
class={bem('icon', [this.shape, { disabled: this.isDisabled, checked }])}
|
class={bem('icon', [this.shape, { disabled: this.isDisabled, checked }])}
|
||||||
style={{ fontSize: addUnit(this.iconSize) }}
|
style={{ fontSize: addUnit(this.iconSize) }}
|
||||||
onClick={this.onClickIcon}
|
|
||||||
>
|
>
|
||||||
{CheckIcon}
|
{CheckIcon}
|
||||||
</div>
|
</div>
|
||||||
@ -84,9 +97,7 @@ export const CheckboxMixin = ({ parent, bem, role }) => ({
|
|||||||
class={bem()}
|
class={bem()}
|
||||||
tabindex={this.tabindex}
|
tabindex={this.tabindex}
|
||||||
aria-checked={String(this.checked)}
|
aria-checked={String(this.checked)}
|
||||||
onClick={event => {
|
onClick={this.onClick}
|
||||||
this.$emit('click', event);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{Children}
|
{Children}
|
||||||
</div>
|
</div>
|
||||||
|
@ -27,16 +27,8 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onClickIcon() {
|
toggle() {
|
||||||
if (!this.isDisabled) {
|
|
||||||
this.currentValue = this.name;
|
this.currentValue = this.name;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
onClickLabel() {
|
|
||||||
if (!this.isDisabled && !this.labelDisabled) {
|
|
||||||
this.currentValue = this.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user