@@ -7,20 +7,36 @@ import KeyCode from 'rc-util/lib/KeyCode';
7
7
import { useComposeRef } from 'rc-util/lib/ref' ;
8
8
import type { ScrollConfig , ScrollTo } from 'rc-virtual-list/lib/List' ;
9
9
import * as React from 'react' ;
10
+ import { useAllowClear } from './hooks/useAllowClear' ;
10
11
import { BaseSelectContext } from './hooks/useBaseProps' ;
11
12
import useDelayReset from './hooks/useDelayReset' ;
12
13
import useLock from './hooks/useLock' ;
13
14
import useSelectTriggerControl from './hooks/useSelectTriggerControl' ;
15
+ import type {
16
+ DisplayInfoType ,
17
+ DisplayValueType ,
18
+ Mode ,
19
+ Placement ,
20
+ RawValueType ,
21
+ RenderDOMFunc ,
22
+ RenderNode ,
23
+ } from './interface' ;
14
24
import type { RefSelectorProps } from './Selector' ;
15
25
import Selector from './Selector' ;
16
26
import type { RefTriggerProps } from './SelectTrigger' ;
17
27
import SelectTrigger from './SelectTrigger' ;
18
28
import TransBtn from './TransBtn' ;
19
29
import { getSeparatedContent } from './utils/valueUtil' ;
20
- import type { DisplayInfoType , DisplayValueType , Mode , Placement , RenderDOMFunc , RenderNode , RawValueType } from './interface' ;
21
- import { useAllowClear } from './hooks/useAllowClear' ;
22
30
23
- export type { DisplayInfoType , DisplayValueType , Mode , Placement , RenderDOMFunc , RenderNode , RawValueType } ;
31
+ export type {
32
+ DisplayInfoType ,
33
+ DisplayValueType ,
34
+ Mode ,
35
+ Placement ,
36
+ RenderDOMFunc ,
37
+ RenderNode ,
38
+ RawValueType ,
39
+ } ;
24
40
25
41
const DEFAULT_OMIT_PROPS = [
26
42
'value' ,
@@ -87,10 +103,10 @@ export interface BaseSelectPrivateProps {
87
103
searchValue : string ,
88
104
info : {
89
105
source :
90
- | 'typing' //User typing
91
- | 'effect' // Code logic trigger
92
- | 'submit' // tag mode only
93
- | 'blur' ; // Not trigger event
106
+ | 'typing' //User typing
107
+ | 'effect' // Code logic trigger
108
+ | 'submit' // tag mode only
109
+ | 'blur' ; // Not trigger event
94
110
} ,
95
111
) => void ;
96
112
/** Trigger when search text match the `tokenSeparators`. Will provide split content */
@@ -153,8 +169,8 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri
153
169
// >>> Icons
154
170
allowClear ?: boolean | { clearIcon ?: RenderNode } ;
155
171
suffixIcon ?: RenderNode ;
156
- /**
157
- * Clear all icon
172
+ /**
173
+ * Clear all icon
158
174
* @deprecated Please use `allowClear` instead
159
175
**/
160
176
clearIcon ?: RenderNode ;
@@ -607,24 +623,12 @@ const BaseSelect = React.forwardRef((props: BaseSelectProps, ref: React.Ref<Base
607
623
} ;
608
624
609
625
// ============================ Dropdown ============================
610
- const [ containerWidth , setContainerWidth ] = React . useState ( null ) ;
611
-
612
626
const [ , forceUpdate ] = React . useState ( { } ) ;
613
627
// We need force update here since popup dom is render async
614
628
function onPopupMouseEnter ( ) {
615
629
forceUpdate ( { } ) ;
616
630
}
617
631
618
- useLayoutEffect ( ( ) => {
619
- if ( triggerOpen ) {
620
- // Guaranteed width accuracy
621
- const newWidth = Math . ceil ( containerRef . current ?. getBoundingClientRect ( ) . width ) ;
622
- if ( containerWidth !== newWidth && ! Number . isNaN ( newWidth ) ) {
623
- setContainerWidth ( newWidth ) ;
624
- }
625
- }
626
- } , [ triggerOpen ] ) ;
627
-
628
632
// Used for raw custom input trigger
629
633
let onTriggerVisibleChange : null | ( ( newOpen : boolean ) => void ) ;
630
634
if ( customizeRawInputElement ) {
@@ -695,22 +699,18 @@ const BaseSelect = React.forwardRef((props: BaseSelectProps, ref: React.Ref<Base
695
699
onInternalSearch ( '' , false , false ) ;
696
700
} ;
697
701
698
- const {
699
- allowClear : mergedAllowClear ,
700
- clearIcon : clearNode
701
- } = useAllowClear (
702
+ const { allowClear : mergedAllowClear , clearIcon : clearNode } = useAllowClear (
702
703
prefixCls ,
703
704
onClearMouseDown ,
704
705
displayValues ,
705
706
allowClear ,
706
707
clearIcon ,
707
708
disabled ,
708
-
709
+
709
710
mergedSearchValue ,
710
711
mode ,
711
712
) ;
712
713
713
-
714
714
// =========================== OptionList ===========================
715
715
const optionList = < OptionList ref = { listRef } /> ;
716
716
@@ -736,7 +736,6 @@ const BaseSelect = React.forwardRef((props: BaseSelectProps, ref: React.Ref<Base
736
736
prefixCls = { prefixCls }
737
737
visible = { triggerOpen }
738
738
popupElement = { optionList }
739
- containerWidth = { containerWidth }
740
739
animation = { animation }
741
740
transitionName = { transitionName }
742
741
dropdownStyle = { dropdownStyle }
0 commit comments