File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -482,13 +482,18 @@ export default {
482482 };
483483 },
484484 choose (country ) {
485- this .activeCountry = country;
486- if (this .inputOptions && this .inputOptions .showDialCode && country) {
487- this .phone = ` +${ country .dialCode } ` ;
488- }
489- if (this .phone && this .phone [0 ] === ' +' ) {
485+ this .activeCountry = country || this .activeCountry || {};
486+
487+ if (this .phone
488+ && this .phone [0 ] === ' +'
489+ && this .activeCountry .iso2
490+ && this .phoneObject .number .national ) {
491+ // Attach the current phone number with the newly selected country
490492 this .phone = PhoneNumber (this .phoneObject .number .national , this .activeCountry .iso2 )
491493 .getNumber (' international' );
494+ } else if (this .inputOptions && this .inputOptions .showDialCode && country) {
495+ // Reset phone if the showDialCode is set
496+ this .phone = ` +${ country .dialCode } ` ;
492497 }
493498 this .$emit (' input' , this .phoneObject .number [this .parsedMode ], this .phoneObject );
494499 this .$emit (' onInput' , this .phoneObject ); // Deprecated
You can’t perform that action at this time.
0 commit comments