Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow country code to be deleted #198

Merged
merged 1 commit into from
Mar 2, 2018

Conversation

MatthewAnstey
Copy link
Contributor

@MatthewAnstey MatthewAnstey commented Feb 24, 2018

Currently country code in the input field can't be deleted on a controlled or uncontrolled component
#197

If the user deletes the numbers of the country code and only has "+" in value. updateFlagFromNumber will populate the flag to the default country which in turn will populate the input field with the default code.

I've removed the setting a default country code because the default country is always the currently selected flag and seems to be redundant (Let me know if i'm wrong ).

Here is where default country is set: https://github.com/MatthewAnstey/react-intl-tel-input/blob/c731a6b913b5d8852d886c4b0e35ae7cbc7c37b7/src/components/IntlTelInputApp.js#L241 on every flag change, making it redundant. I think its redundant because its the same as the currently selected flag.

Although this fixes the bug. I think we should decide what default country was suppose to do (apart from obviously setting the default country). I'm guessing it was meant to update the flag to default flag when just '+' was typed? If this is case I think we should remove https://github.com/MatthewAnstey/react-intl-tel-input/blob/c731a6b913b5d8852d886c4b0e35ae7cbc7c37b7/src/components/IntlTelInputApp.js#L241 and look at a different fix for this.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 94.02% when pulling c731a6b on MatthewAnstey:bug/delete-country-code into dcfe6e2 on patw0929:master.

@patw0929
Copy link
Owner

patw0929 commented Mar 1, 2018

Thanks for the PR! 🙌
I think it's ok to keep selected flag when just type +.
Because it has same behavior in previous version, right?

@MatthewAnstey
Copy link
Contributor Author

No problem! Yeah it has the same behaviour.

@patw0929 patw0929 merged commit bacea02 into patw0929:master Mar 2, 2018
patw0929 added a commit that referenced this pull request Mar 2, 2018
Bug fixes:

* #198 Allow country code to be deleted (Fixed #197) (c731a6b by @MatthewAnstey)
andrewsantarin pushed a commit to andrewsantarin/react-intl-tel-input that referenced this pull request Feb 2, 2022
andrewsantarin pushed a commit to andrewsantarin/react-intl-tel-input that referenced this pull request Feb 2, 2022
Bug fixes:

* patw0929#198 Allow country code to be deleted (Fixed patw0929#197) (c731a6b by @MatthewAnstey)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants