@@ -15,6 +15,7 @@ import useFormInstance from "antd/es/form/hooks/useFormInstance";
1515import { ConfigContext } from "antd/es/config-provider" ;
1616import { FormContext } from "antd/es/form/context" ;
1717import { useWatch } from "antd/es/form/Form" ;
18+ import version from "antd/es/version" ;
1819import Select from "antd/es/select" ;
1920import Input from "antd/es/input" ;
2021
@@ -36,6 +37,10 @@ import locale from "./locale";
3637import { injectMergedStyles } from "./styles" ;
3738import { PhoneInputProps , PhoneNumber } from "./types" ;
3839
40+ const [ major , minor , _ ] = version . split ( "." ) . map ( Number ) ;
41+ const isV5x = major === 5 ;
42+ const isV5x25 = isV5x && minor >= 25 ;
43+
3944const PhoneInput = forwardRef ( ( {
4045 value : initialValue = "" ,
4146 country = getDefaultISO2Code ( ) ,
@@ -221,9 +226,9 @@ const PhoneInput = forwardRef(({
221226 inputRef . current . input . focus ( ) ;
222227 } }
223228 optionLabelProp = "label"
224- dropdownStyle = { { minWidth } }
225- onDropdownVisibleChange = { onDropdownVisibleChange }
226- dropdownRender = { ( menu ) => (
229+ { ... ( isV5x ? { onOpenChange : onDropdownVisibleChange } : { onDropdownVisibleChange } ) }
230+ { ... ( isV5x25 ? { styles : { popup : { root : { minWidth } } } } : { dropdownStyle : { minWidth } } ) }
231+ { ... ( { [ isV5x ? "popupRender" : "dropdownRender" ] : ( menu : any ) => (
227232 < div className = { `${ prefixCls } -phone-input-search-wrapper` } >
228233 { enableSearch && (
229234 < Input
@@ -237,7 +242,7 @@ const PhoneInput = forwardRef(({
237242 < div className = "ant-select-item-empty" > { searchNotFound } </ div >
238243 ) }
239244 </ div >
240- ) }
245+ ) } ) }
241246 >
242247 < Select . Option
243248 children = { null }
0 commit comments