File tree Expand file tree Collapse file tree
workspaces/sandbox/plugins/sandbox/src/components/Modals/PhoneVerificationSteps Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515 */
1616import React , { ForwardedRef , forwardRef } from 'react' ;
1717import { E164Number } from 'libphonenumber-js/types.cjs' ;
18- import {
19- default as RPNInput ,
20- Country ,
21- getCountryCallingCode ,
22- } from 'react-phone-number-input' ;
18+ import { default as RPNInput , Country } from 'react-phone-number-input' ;
2319import { useTheme } from '@mui/material/styles' ;
2420import Box from '@mui/material/Box' ;
2521import Button from '@mui/material/Button' ;
@@ -34,7 +30,7 @@ import DialogContentText from '@mui/material/DialogContentText';
3430import DialogActions from '@mui/material/DialogActions' ;
3531import IconButton from '@mui/material/IconButton' ;
3632import CloseIcon from '@mui/icons-material/Close' ;
37- import InputAdornment from '@mui/material/InputAdornment' ;
33+
3834import CircularProgress from '@mui/material/CircularProgress' ;
3935
4036const FLAG_FETCH_URL =
@@ -81,15 +77,6 @@ export const PhoneNumberStep: React.FC<PhoneNumberFormProps> = ({
8177 { ...props }
8278 // eslint-disable-next-line jsx-a11y/no-autofocus
8379 autoFocus
84- InputProps = { {
85- startAdornment : country ? (
86- < InputAdornment position = "start" >
87- < Typography color = "textPrimary" style = { { fontSize : '16px' } } >
88- +{ getCountryCallingCode ( country ) }
89- </ Typography >
90- </ InputAdornment >
91- ) : undefined ,
92- } }
9380 />
9481 ) ;
9582 } ) ;
Original file line number Diff line number Diff line change @@ -145,4 +145,23 @@ describe('PhoneNumberStep', () => {
145145 phoneInput . querySelector ( '[data-testid="tel-input"] input' ) ,
146146 ) . toHaveValue ( '' ) ;
147147 } ) ;
148+
149+ test ( 'should not display duplicate country code in phone input field' , ( ) => {
150+ const usPhoneNumber = parsePhoneNumber ( '+17373072270' , 'US' ) ;
151+ render (
152+ < PhoneNumberStep
153+ phoneNumber = { usPhoneNumber . number }
154+ setPhoneNumber = { mockSetPhoneNumber }
155+ handleClose = { mockHandleClose }
156+ handlePhoneNumberSubmit = { mockHandlePhoneNumberSubmit }
157+ setCountry = { mockSetCountry }
158+ country = "US"
159+ /> ,
160+ ) ;
161+
162+ const phoneInput = screen . getByTestId ( 'tel-input' ) ;
163+ const inputElement = phoneInput . querySelector ( 'input' ) ;
164+ const inputValue = inputElement ?. value || '' ;
165+ expect ( inputValue ) . toBe ( '+1 737 307 2270' ) ;
166+ } ) ;
148167} ) ;
You can’t perform that action at this time.
0 commit comments