-
Notifications
You must be signed in to change notification settings - Fork 546
Closed
Description
I am using the feature where you pass null as the value of the PhoneInput, in order to clear out the currently selected country in the country dropdown. In some scenarios, this is not working correctly and causes an exception.
Here are the steps to reproduce:
- Start with input value being a string (either empty string or non-empty string)
- Set PhoneInput value to
null(in my case I have a button which I press that does this) - Choose a country in the country dropdown
- Set PhoneInput value to
nullagain - Do not choose a country in the country dropdown, and instead start typing a value in the input
At this point an exception occurs:
TypeError: Cannot read property 'length' of undefined
PhoneInput.handleInput
src/components/PhoneInput/index.js:556
553 | // we don't need to send the whole number to guess the country... only the first 6 characters are enough
554 | // the guess country function can then use memoization much more effectively since the set of input it
555 | // gets has drastically reduced
> 556 | if (!this.state.freezeSelection || selectedCountry.dialCode.length > inputNumber.length) {
| ^ 557 | if (this.props.disableCountryGuess) {newSelectedCountry = selectedCountry;}
558 | else {
559 | newSelectedCountry = this.guessSelectedCountry(inputNumber.substring(0, 6), country, onlyCountries, hiddenAreaCodes) || selectedCountry;
Metadata
Metadata
Assignees
Labels
No labels