From a0fce2096d6cd452eebaf45a1085c4ec1877259c Mon Sep 17 00:00:00 2001 From: Dhanesh Kapadiya <11155587+dhanesh-kapadiya@users.noreply.github.com> Date: Tue, 14 May 2019 04:20:09 +0530 Subject: [PATCH 1/3] update flag when defaultCountry props value is changed --- README.md | 1 - src/components/IntlTelInput.js | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eb29f50c9..e79c7b082 100644 --- a/README.md +++ b/README.md @@ -119,4 +119,3 @@ yarn run lint MIT Copyright (c) 2015-2019 patw. - diff --git a/src/components/IntlTelInput.js b/src/components/IntlTelInput.js index 03ec81a01..da1044275 100644 --- a/src/components/IntlTelInput.js +++ b/src/components/IntlTelInput.js @@ -163,6 +163,10 @@ class IntlTelInput extends Component { if (this.props.allowDropdown !== prevProps.allowDropdown) { this.allowDropdown = this.props.allowDropdown; } + + if (this.props.defaultCountry !== prevProps.defaultCountry) { + this.updateFlagOnDefaultCountryChange(this.props.defaultCountry) + } } componentWillUnmount() { @@ -171,6 +175,11 @@ class IntlTelInput extends Component { this.unbindDocumentClick(); } + // Updates flag when value of defaultCountry props change + updateFlagOnDefaultCountryChange = (countryCode) => { + this.setFlag(countryCode, false) + }; + getTempCountry = countryCode => { if (countryCode === 'auto') { return 'auto'; @@ -211,7 +220,7 @@ class IntlTelInput extends Component { }; // select the given flag, update the placeholder and the active list item - // Note: called from setInitialState, updateFlagFromNumber, selectListItem, setCountry + // Note: called from setInitialState, updateFlagFromNumber, selectListItem, setCountry, updateFlagOnDefaultCountryChange setFlag = (countryCode, isInit) => { const prevCountry = this.selectedCountryData && this.selectedCountryData.iso2 @@ -1245,6 +1254,8 @@ class IntlTelInput extends Component { } }; + + render() { this.wrapperClass[this.props.containerClassName] = true; const inputClass = this.props.inputClassName; From faa4de2b16a6ec8b9b7461fb7c49956a23b7a88d Mon Sep 17 00:00:00 2001 From: Dhanesh Kapadiya <11155587+dhanesh-kapadiya@users.noreply.github.com> Date: Tue, 14 May 2019 04:24:24 +0530 Subject: [PATCH 2/3] remove extra space --- src/components/IntlTelInput.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/IntlTelInput.js b/src/components/IntlTelInput.js index da1044275..fef0f2c76 100644 --- a/src/components/IntlTelInput.js +++ b/src/components/IntlTelInput.js @@ -1254,8 +1254,6 @@ class IntlTelInput extends Component { } }; - - render() { this.wrapperClass[this.props.containerClassName] = true; const inputClass = this.props.inputClassName; From 0336b10ed187a5c6a90b7125c74a99b58b311757 Mon Sep 17 00:00:00 2001 From: Dhanesh Kapadiya <11155587+dhanesh-kapadiya@users.noreply.github.com> Date: Tue, 14 May 2019 10:58:40 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e79c7b082..c02791a3f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +*This project is an instance of original project made by [Patrick Wang](https://github.com/patw0929). +Because of the lack of activity on original repo, I have added some functionalities and published it on npmjs for my own personal use. +Copyright (c) 2015-2019 [Patrick Wang](https://github.com/patw0929).* + # React-Intl-Tel-Input [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)