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
4 changes: 1 addition & 3 deletions src/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,7 @@ const Cascader = React.forwardRef((props: CascaderProps, ref: React.Ref<Cascader
showSearch={mergedShowSearch}
onSearch={setMergedSearch}
labelRender={labelRender}
{...{
getRawInputElement: () => children,
}}
getRawInputElement={() => children}
/>
</CascaderContext.Provider>
);
Expand Down
4 changes: 3 additions & 1 deletion src/OptionList/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface ColumnProps {
checkedSet: Set<React.Key>;
halfCheckedSet: Set<React.Key>;
loadingKeys: React.Key[];
isEmpty: boolean;
}

export default function Column({
Expand All @@ -32,6 +33,7 @@ export default function Column({
checkedSet,
halfCheckedSet,
loadingKeys,
isEmpty,
}: ColumnProps) {
const menuPrefixCls = `${prefixCls}-menu`;
const menuItemPrefixCls = `${prefixCls}-menu-item`;
Expand Down Expand Up @@ -107,7 +109,7 @@ export default function Column({
}
}}
>
{multiple && (
{multiple && !isEmpty && (
<Checkbox
prefixCls={`${prefixCls}-checkbox`}
checked={checked}
Expand Down
1 change: 1 addition & 0 deletions src/OptionList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ const RefOptionList = React.forwardRef<RefOptionListProps, OptionListProps>((pro
key={index}
index={index}
{...columnProps}
isEmpty={isEmpty}
prefixCls={mergedPrefixCls}
options={col.options}
openKey={mergedOpenPath[index]}
Expand Down
7 changes: 3 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Cascader, { CascaderProps } from './Cascader';
import { FieldNames, DataNode, ShowSearchType } from './interface';

export { CascaderProps, FieldNames, DataNode, ShowSearchType };
import Cascader from './Cascader';

export type { CascaderProps } from './Cascader';
export type { FieldNames, DataNode, ShowSearchType } from './interface';
export default Cascader;
13 changes: 13 additions & 0 deletions tests/checkable.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('Cascader.Checkable', () => {
],
);
});

it('click checkobx invoke one onChange', () => {
const onChange = jest.fn();
const wrapper = mount(<Cascader options={options} onChange={onChange} open checkable />);
Expand All @@ -89,4 +90,16 @@ describe('Cascader.Checkable', () => {
expect(wrapper.exists('.rc-cascader-checkbox-checked')).toBeTruthy();
expect(onChange).toHaveBeenCalledTimes(1);
});

// https://github.com/ant-design/ant-design/issues/33302
it('should not display checkbox when children is empty', () => {
const wrapper = mount(
<Cascader checkable options={[]}>
<input readOnly />
</Cascader>,
);
wrapper.find('input').simulate('click');
const menus = wrapper.find('.rc-cascader-menu');
expect(menus.find('.rc-cascader-checkbox').length).toBe(0);
});
});