@@ -29,7 +29,7 @@ import PickerContext from './context';
2929import useCellRender from './hooks/useCellRender' ;
3030import useFieldsInvalidate from './hooks/useFieldsInvalidate' ;
3131import useFilledProps from './hooks/useFilledProps' ;
32- import useFocusControl from './hooks/useFocusControl' ;
32+ import useFocusControl , { isPickerElement } from './hooks/useFocusControl' ;
3333import useOpen from './hooks/useOpen' ;
3434import usePickerRef from './hooks/usePickerRef' ;
3535import usePresets from './hooks/usePresets' ;
@@ -236,6 +236,7 @@ function RangePicker<DateType extends object = any>(
236236
237237 // ========================= Refs =========================
238238 const selectorRef = usePickerRef ( ref ) ;
239+ const popupRef = React . useRef < HTMLDivElement > ( null ) ;
239240
240241 // ======================= Semantic =======================
241242 const [ mergedClassNames , mergedStyles ] = useSemantic ( propClassNames , propStyles ) ;
@@ -346,15 +347,9 @@ function RangePicker<DateType extends object = any>(
346347 resetValue ,
347348 ) ;
348349
349- const isPickerElement = useEvent ( ( element : EventTarget | null ) => {
350- const target = element as HTMLElement ;
351-
352- return (
353- ! ! target &&
354- ( selectorRef . current . nativeElement . contains ( target ) ||
355- ! ! target . closest ?.( `.${ prefixCls } -panel-container` ) )
356- ) ;
357- } ) ;
350+ const isInternalPickerElement = useEvent ( ( element : EventTarget | null ) =>
351+ isPickerElement ( element , selectorRef . current . nativeElement , popupRef . current ) ,
352+ ) ;
358353
359354 const triggerFocusChange = useEvent ( ( index : number , type : 'focus' | 'blur' ) => {
360355 const nextFocused = type === 'focus' ;
@@ -367,7 +362,7 @@ function RangePicker<DateType extends object = any>(
367362 } ) ;
368363
369364 const [ onFieldFocus , onFieldBlur ] = useFocusControl (
370- isPickerElement ,
365+ isInternalPickerElement ,
371366 triggerFocusChange ,
372367 ( index , event ) => {
373368 onFocus ?.( event , {
@@ -620,6 +615,7 @@ function RangePicker<DateType extends object = any>(
620615 // >>> Render
621616 const panel = (
622617 < Popup < any >
618+ containerRef = { popupRef }
623619 // MISC
624620 { ...panelProps }
625621 showNow = { mergedShowNow }
0 commit comments