Skip to content

Commit 8e9bd3b

Browse files
author
committed
feat: support dropdownStyle
1 parent 6ba06e9 commit 8e9bd3b

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/Cascader.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { BuildInPlacements } from '@rc-component/trigger/lib/interface';
2-
import type { BaseSelectProps, BaseSelectPropsWithoutPrivate, BaseSelectRef } from 'rc-select';
2+
import type { BaseSelectProps,BaseSelectPropsWithoutPrivate,BaseSelectRef } from 'rc-select';
33
import { BaseSelect } from 'rc-select';
4-
import type { DisplayValueType, Placement } from 'rc-select/lib/BaseSelect';
4+
import type { DisplayValueType,Placement } from 'rc-select/lib/BaseSelect';
55
import useId from 'rc-select/lib/hooks/useId';
66
import { conductCheck } from 'rc-tree/lib/utils/conductUtil';
77
import useMergedState from 'rc-util/lib/hooks/useMergedState';
@@ -14,9 +14,9 @@ import useRefFunc from './hooks/useRefFunc';
1414
import useSearchConfig from './hooks/useSearchConfig';
1515
import useSearchOptions from './hooks/useSearchOptions';
1616
import OptionList from './OptionList';
17-
import { fillFieldNames, SHOW_CHILD, SHOW_PARENT, toPathKey, toPathKeys } from './utils/commonUtil';
18-
import { formatStrategyValues, toPathOptions } from './utils/treeUtil';
19-
import warningProps, { warningNullOptions } from './utils/warningPropsUtil';
17+
import { fillFieldNames,SHOW_CHILD,SHOW_PARENT,toPathKey,toPathKeys } from './utils/commonUtil';
18+
import { formatStrategyValues,toPathOptions } from './utils/treeUtil';
19+
import warningProps,{ warningNullOptions } from './utils/warningPropsUtil';
2020

2121
export interface ShowSearchType<OptionType extends BaseOptionType = DefaultOptionType> {
2222
filter?: (inputValue: string, options: OptionType[], fieldNames: FieldNames) => boolean;
@@ -199,6 +199,7 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re
199199

200200
popupClassName,
201201
dropdownClassName,
202+
dropdownStyle,
202203
dropdownMenuColumnStyle,
203204

204205
popupPlacement,
@@ -473,14 +474,16 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re
473474
// ==============================================================
474475
const emptyOptions = !(mergedSearchValue ? searchOptions : mergedOptions).length;
475476

476-
const dropdownStyle: React.CSSProperties =
477+
const mergedDropdownStyle: React.CSSProperties =
477478
// Search to match width
478-
(mergedSearchValue && searchConfig.matchInputWidth) ||
479-
// Empty keep the width
480-
emptyOptions
481-
? {}
479+
dropdownStyle ?? (mergedSearchValue && searchConfig.matchInputWidth) ?? emptyOptions
480+
? // Empty keep the width
481+
{
482+
...dropdownStyle,
483+
}
482484
: {
483485
minWidth: 'auto',
486+
...dropdownStyle,
484487
};
485488

486489
return (
@@ -492,7 +495,7 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re
492495
id={mergedId}
493496
prefixCls={prefixCls}
494497
dropdownMatchSelectWidth={dropdownMatchSelectWidth}
495-
dropdownStyle={dropdownStyle}
498+
dropdownStyle={mergedDropdownStyle}
496499
// Value
497500
displayValues={displayValues}
498501
onDisplayValuesChange={onDisplayValuesChange}

0 commit comments

Comments
 (0)