Skip to content

Commit

Permalink
fix(Checkbox): fixed the issue that disabled is invalid when using op… (
Browse files Browse the repository at this point in the history
#1713)

* fix(Checkbox): fixed the issue that disabled is invalid when using options attribute

* chore: update snapshot

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
anlyyao and github-actions[bot] authored Jan 7, 2025
1 parent c416cb9 commit 2805808
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 34 deletions.
24 changes: 12 additions & 12 deletions src/checkbox/__test__/__snapshots__/demo.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`Checkbox > Checkbox allVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -74,7 +74,7 @@ exports[`Checkbox > Checkbox allVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -111,7 +111,7 @@ exports[`Checkbox > Checkbox allVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -197,7 +197,7 @@ exports[`Checkbox > Checkbox baseVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -234,7 +234,7 @@ exports[`Checkbox > Checkbox baseVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -265,7 +265,7 @@ exports[`Checkbox > Checkbox baseVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -616,7 +616,7 @@ exports[`Checkbox > Checkbox mobileVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -653,7 +653,7 @@ exports[`Checkbox > Checkbox mobileVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -684,7 +684,7 @@ exports[`Checkbox > Checkbox mobileVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -917,7 +917,7 @@ exports[`Checkbox > Checkbox mobileVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -954,7 +954,7 @@ exports[`Checkbox > Checkbox mobileVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down Expand Up @@ -991,7 +991,7 @@ exports[`Checkbox > Checkbox mobileVue demo works fine 1`] = `
<div
class="t-checkbox__description"
>
<!---->
</div>
</div>
<div
Expand Down
20 changes: 2 additions & 18 deletions src/checkbox/checkbox-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,15 @@ export default defineComponent({
innerValue,
checkAllStatus,
checkedSet,
maxExceeded,
onCheckedChange,
});
return () => {
const checkboxNode = () => {
return (
<span>
{optionList.value.map((item, idx) => (
<checkbox
key={idx}
name={item.name || ''}
label={item.label || item.text || ''}
value={item.value}
check-all={item.checkAll}
block={item.block || true}
checked={item.checked || false}
content={item.content || ''}
content-disabled={item.contentDisabled || false}
icon={item.icon || 'circle'}
indeterminate={item.indeterminate || false}
disabled={item.disabled}
max-content-row={item.maxContentRow || 5}
max-label-row={item.maxLabelRow || 3}
readonly={item.readonly || false}
placement={item.placement || 'left'}
/>
<Checkbox {...item} key={`${item.value || ''}${idx}`} label={item.label || item.text || ''} />
))}
</span>
);
Expand Down
6 changes: 3 additions & 3 deletions src/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export default defineComponent({
});

const isDisabled = computed(() => {
if (checkboxGroup?.max.value)
return checkboxGroup.max.value <= checkboxGroup.innerValue.value.length && !isChecked.value;

if (!props.checkAll && !isChecked.value && checkboxGroup?.maxExceeded.value) {
return true;
}
return disabled.value;
});

Expand Down
1 change: 0 additions & 1 deletion src/checkbox/hooks/getOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const getOptions = (props: any, slots: Slots) => {
r = { label: String(item), value: item };
} else {
r = { ...item };
r.disabled = r.disabled === undefined ? props.disabled : r.disabled;
}
return r;
});
Expand Down

0 comments on commit 2805808

Please sign in to comment.