Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/OptionList/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export default function Column({
// >>>>> checked
const checked = checkedSet.has(fullPathKey);

// >>>>> halfChecked
const halfChecked = halfCheckedSet.has(fullPathKey);

// >>>>> Open
const triggerOpenPath = () => {
if (!disabled && (!hoverOpen || !isMergedLeaf)) {
Expand Down Expand Up @@ -131,7 +134,7 @@ export default function Column({
<Checkbox
prefixCls={`${prefixCls}-checkbox`}
checked={checked}
halfChecked={halfCheckedSet.has(value)}
halfChecked={halfChecked}
disabled={disabled}
onClick={(e: React.MouseEvent<HTMLSpanElement>) => {
e.stopPropagation();
Expand Down
20 changes: 20 additions & 0 deletions tests/checkable.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('Cascader.Checkable', () => {

// Check cards
wrapper.clickOption(2, 1);
expect(wrapper.find('.rc-cascader-checkbox-indeterminate')).toHaveLength(2);
expect(wrapper.exists('.rc-cascader-checkbox-indeterminate')).toBeTruthy();
expect(onChange).toHaveBeenCalledWith(
[
Expand All @@ -75,6 +76,25 @@ describe('Cascader.Checkable', () => {
],
],
);

// Check fish
wrapper.clickOption(2, 0);
expect(wrapper.find('.rc-cascader-checkbox-indeterminate')).toHaveLength(0);
expect(wrapper.find('.rc-cascader-checkbox-checked')).toHaveLength(5);
expect(onChange).toHaveBeenCalledWith(
[
// Light
['light'],
// Bamboo
['bamboo'],
],
[
// Light
[expect.objectContaining({ value: 'light' })],
// Cards
[expect.objectContaining({ value: 'bamboo' })],
],
);
});
it('click checkbox invoke one onChange', () => {
const onChange = jest.fn();
Expand Down