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
10 changes: 9 additions & 1 deletion examples/multiple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React from 'react';
import '../assets/index.less';
import Cascader from '../src';
const { SHOW_CHILD } = Cascader;

const optionLists = [
{
Expand Down Expand Up @@ -46,7 +47,14 @@ const Demo = () => {

// 直接选中一级选项,但是此时二级选项没有全部选中
return (
<Cascader checkable options={options} loadData={loadData} onChange={onChange} changeOnSelect />
<Cascader
checkable
options={options}
showCheckedStrategy={SHOW_CHILD}
loadData={loadData}
onChange={onChange}
changeOnSelect
/>
);
};

Expand Down
9 changes: 6 additions & 3 deletions src/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import type { BaseSelectRef, BaseSelectPropsWithoutPrivate, BaseSelectProps } fr
import { BaseSelect } from 'rc-select';
import OptionList from './OptionList';
import CascaderContext from './context';
import type { SHOW_CHILD } from './utils/commonUtil';
import { fillFieldNames, toPathKey, toPathKeys, SHOW_PARENT } from './utils/commonUtil';
import { fillFieldNames, toPathKey, toPathKeys, SHOW_PARENT, SHOW_CHILD } from './utils/commonUtil';
import useDisplayValues from './hooks/useDisplayValues';
import useRefFunc from './hooks/useRefFunc';
import useEntities from './hooks/useEntities';
Expand Down Expand Up @@ -522,16 +521,20 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re
/>
</CascaderContext.Provider>
);
}) as (<OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(
}) as unknown as (<OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(
props: React.PropsWithChildren<CascaderProps<OptionType>> & {
ref?: React.Ref<BaseSelectRef>;
},
) => React.ReactElement) & {
displayName?: string;
SHOW_PARENT: typeof SHOW_PARENT;
SHOW_CHILD: typeof SHOW_CHILD;
};

if (process.env.NODE_ENV !== 'production') {
Cascader.displayName = 'Cascader';
}

Cascader.SHOW_PARENT = SHOW_PARENT;
Cascader.SHOW_CHILD = SHOW_CHILD;
export default Cascader;