@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
import Trigger from 'rc-trigger' ;
3
3
import classNames from 'classnames' ;
4
4
import type { RenderDOMFunc } from './interface' ;
5
+ import type { Placement } from './generate' ;
5
6
6
7
const getBuiltInPlacements = ( dropdownMatchSelectWidth : number | boolean ) => {
7
8
// Enable horizontal overflow auto-adjustment when a custom dropdown width is provided
@@ -57,6 +58,7 @@ export interface SelectTriggerProps {
57
58
animation ?: string ;
58
59
transitionName ?: string ;
59
60
containerWidth : number ;
61
+ placement ?: Placement ;
60
62
dropdownStyle : React . CSSProperties ;
61
63
dropdownClassName : string ;
62
64
direction : string ;
@@ -86,6 +88,7 @@ const SelectTrigger: React.RefForwardingComponent<RefTriggerProps, SelectTrigger
86
88
dropdownStyle,
87
89
dropdownClassName,
88
90
direction = 'ltr' ,
91
+ placement,
89
92
dropdownMatchSelectWidth = true ,
90
93
dropdownRender,
91
94
dropdownAlign,
@@ -103,9 +106,10 @@ const SelectTrigger: React.RefForwardingComponent<RefTriggerProps, SelectTrigger
103
106
popupNode = dropdownRender ( popupElement ) ;
104
107
}
105
108
106
- const builtInPlacements = React . useMemo ( ( ) => getBuiltInPlacements ( dropdownMatchSelectWidth ) , [
107
- dropdownMatchSelectWidth ,
108
- ] ) ;
109
+ const builtInPlacements = React . useMemo (
110
+ ( ) => getBuiltInPlacements ( dropdownMatchSelectWidth ) ,
111
+ [ dropdownMatchSelectWidth ] ,
112
+ ) ;
109
113
110
114
// ===================== Motion ======================
111
115
const mergedTransitionName = animation ? `${ dropdownPrefixCls } -${ animation } ` : transitionName ;
@@ -133,7 +137,7 @@ const SelectTrigger: React.RefForwardingComponent<RefTriggerProps, SelectTrigger
133
137
{ ...restProps }
134
138
showAction = { onPopupVisibleChange ? [ 'click' ] : [ ] }
135
139
hideAction = { onPopupVisibleChange ? [ 'click' ] : [ ] }
136
- popupPlacement = { direction === 'rtl' ? 'bottomRight' : 'bottomLeft' }
140
+ popupPlacement = { placement || ( direction === 'rtl' ? 'bottomRight' : 'bottomLeft' ) }
137
141
builtinPlacements = { builtInPlacements }
138
142
prefixCls = { dropdownPrefixCls }
139
143
popupTransitionName = { mergedTransitionName }
0 commit comments