Skip to content

Commit 475493c

Browse files
committed
fix #226
1 parent 6eb8412 commit 475493c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,13 @@ class PhoneInput extends React.Component {
313313
let newSelectedCountry, formattedNumber;
314314

315315
// if new value start with selectedCountry.dialCode, format number, otherwise find newSelectedCountry
316-
if (selectedCountry && startsWith(value, selectedCountry.dialCode)) {
316+
if (selectedCountry && startsWith(value, prefix + selectedCountry.dialCode)) {
317317
formattedNumber = this.formatNumber(inputNumber, selectedCountry);
318318
this.setState({ formattedNumber });
319319
}
320320
else {
321321
newSelectedCountry = this.guessSelectedCountry(inputNumber.substring(0, 6), country, onlyCountries, hiddenAreaCodes) || selectedCountry;
322-
const dialCode = newSelectedCountry && startsWith(inputNumber, newSelectedCountry.dialCode) ? newSelectedCountry.dialCode : '';
322+
const dialCode = newSelectedCountry && startsWith(inputNumber, prefix + newSelectedCountry.dialCode) ? newSelectedCountry.dialCode : '';
323323

324324
formattedNumber = this.formatNumber(
325325
(this.props.disableCountryCode ? '' : dialCode) + inputNumber,

0 commit comments

Comments
 (0)