@@ -4,6 +4,7 @@ import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
4
4
import useMergedState from '@rc-component/util/lib/hooks/useMergedState' ;
5
5
import isMobile from '@rc-component/util/lib/isMobile' ;
6
6
import { useComposeRef } from '@rc-component/util/lib/ref' ;
7
+ import { getDOM } from '@rc-component/util/lib/Dom/findDOMNode' ;
7
8
import type { ScrollConfig , ScrollTo } from 'rc-virtual-list/lib/List' ;
8
9
import * as React from 'react' ;
9
10
import { useAllowClear } from '../hooks/useAllowClear' ;
@@ -330,11 +331,11 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
330
331
331
332
// ============================== Refs ==============================
332
333
const containerRef = React . useRef < HTMLDivElement > ( null ) ;
333
- const selectorDomRef = React . useRef < HTMLDivElement > ( null ) ;
334
334
const triggerRef = React . useRef < RefTriggerProps > ( null ) ;
335
335
const selectorRef = React . useRef < RefSelectorProps > ( null ) ;
336
336
const listRef = React . useRef < RefOptionListProps > ( null ) ;
337
337
const blurRef = React . useRef < boolean > ( false ) ;
338
+ const customDomRef = React . useRef < HTMLElement > ( null ) ;
338
339
339
340
/** Used for component focused management */
340
341
const [ mockFocused , setMockFocused , cancelSetMockFocused ] = useDelayReset ( ) ;
@@ -344,7 +345,10 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
344
345
focus : selectorRef . current ?. focus ,
345
346
blur : selectorRef . current ?. blur ,
346
347
scrollTo : ( arg ) => listRef . current ?. scrollTo ( arg ) ,
347
- nativeElement : containerRef . current || selectorDomRef . current ,
348
+ nativeElement :
349
+ containerRef . current ||
350
+ selectorRef . current ?. nativeElement ||
351
+ ( getDOM ( customDomRef . current ) as HTMLElement ) ,
348
352
} ) ) ;
349
353
350
354
// ========================== Search Value ==========================
@@ -368,7 +372,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
368
372
typeof getRawInputElement === 'function' && getRawInputElement ( ) ;
369
373
370
374
const customizeRawInputRef = useComposeRef < HTMLElement > (
371
- selectorDomRef ,
375
+ customDomRef ,
372
376
customizeRawInputElement ?. props ?. ref ,
373
377
) ;
374
378
@@ -808,12 +812,6 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
808
812
builtinPlacements = { builtinPlacements }
809
813
getPopupContainer = { getPopupContainer }
810
814
empty = { emptyOptions }
811
- getTriggerDOMNode = { ( node ) =>
812
- // TODO: This is workaround and should be removed in `rc-select`
813
- // And use new standard `nativeElement` for ref.
814
- // But we should update `rc-resize-observer` first.
815
- selectorDomRef . current || node
816
- }
817
815
onPopupVisibleChange = { onTriggerVisibleChange }
818
816
onPopupMouseEnter = { onPopupMouseEnter }
819
817
>
@@ -826,7 +824,6 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
826
824
{ ...props }
827
825
prefixClassName = { classNames ?. prefix }
828
826
prefixStyle = { styles ?. prefix }
829
- domRef = { selectorDomRef }
830
827
prefixCls = { prefixCls }
831
828
inputElement = { customizeInputElement }
832
829
ref = { selectorRef }
0 commit comments