Skip to content

Commit

Permalink
feat: support dropdownStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
committed Jun 5, 2023
1 parent 6ba06e9 commit f3488fb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re

popupClassName,
dropdownClassName,
dropdownStyle,
dropdownMenuColumnStyle,

popupPlacement,
Expand Down Expand Up @@ -473,15 +474,17 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re
// ==============================================================
const emptyOptions = !(mergedSearchValue ? searchOptions : mergedOptions).length;

const dropdownStyle: React.CSSProperties =
const mergedDropdownStyle: React.CSSProperties = React.useMemo(() => {
// Search to match width
(mergedSearchValue && searchConfig.matchInputWidth) ||
// Empty keep the width
emptyOptions
? {}
return dropdownStyle ?? (mergedSearchValue && searchConfig.matchInputWidth) ?? emptyOptions
? // Empty keep the width
{
...dropdownStyle,
}
: {
minWidth: 'auto',
};
}, [dropdownStyle, mergedSearchValue, searchConfig, emptyOptions]);

return (
<CascaderContext.Provider value={cascaderContext}>
Expand All @@ -492,7 +495,7 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re
id={mergedId}
prefixCls={prefixCls}
dropdownMatchSelectWidth={dropdownMatchSelectWidth}
dropdownStyle={dropdownStyle}
dropdownStyle={mergedDropdownStyle}
// Value
displayValues={displayValues}
onDisplayValuesChange={onDisplayValuesChange}
Expand Down

0 comments on commit f3488fb

Please sign in to comment.