Skip to content

Commit cbc060e

Browse files
fix phone number alert in profile settings
1 parent 442830d commit cbc060e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/routes/settings/routes/profile/components/ProfileSettingsForm.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ class ProfileSettingsForm extends Component {
5353
}
5454

5555
onBusinessPhoneCountryChange({ country, externalChange }) {
56-
const { businessPhoneValid } = this.state
56+
const { businessPhoneValid, countrySelected: previousSelectedCountry } = this.state
5757

5858
if (country && country.code) {
59-
if (this.state.countrySelected !== country.name && country.name) {
59+
if (previousSelectedCountry !== country.name && country.name) {
6060
// when country code of business phone changes, the country selection should change automatically
6161
this.refs.countrySelect.setValue(country.name)
6262
this.setState({
@@ -78,7 +78,9 @@ class ProfileSettingsForm extends Component {
7878
// external change means, the user didn't change the phone number field.
7979
// But it was automatically changed due to country selection change. In such case, we should show
8080
// the alert under country selection only.
81-
if (!externalChange) {
81+
const countryName = country && country.name
82+
const countryCodeChanged = countryName && previousSelectedCountry && countryName !== previousSelectedCountry
83+
if (!externalChange && countryCodeChanged) {
8284
this.setState({
8385
businessPhoneDirty: true
8486
})

0 commit comments

Comments
 (0)