Skip to content

Commit

Permalink
Merge remote-tracking branch 'cialfo/bugfix/fix-countries-sorting' in…
Browse files Browse the repository at this point in the history
…to bugfix/fix-countries-sorting
  • Loading branch information
cmckni3 committed Jan 31, 2025
2 parents 124d037 + b15dd5a commit 6af8dfb
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ export class NgxIntlTelInputComponent implements OnInit, OnChanges {
}

/*
This is a wrapper method to avoid calling this.ngOnInit() in writeValue().
Ref: http://codelyzer.com/rules/no-life-cycle-call/
*/
This is a wrapper method to avoid calling this.ngOnInit() in writeValue().
Ref: http://codelyzer.com/rules/no-life-cycle-call/
*/
init() {
this.fetchCountryData();
if (this.preferredCountries.length) {
Expand Down Expand Up @@ -227,6 +227,7 @@ export class NgxIntlTelInputComponent implements OnInit, OnChanges {
: this.selectedCountry.iso2;
if (countryCode && countryCode !== this.selectedCountry.iso2) {
const newCountry = this.allCountries
.slice()
.sort((a, b) => {
return a.priority - b.priority;
})
Expand Down Expand Up @@ -418,9 +419,9 @@ export class NgxIntlTelInputComponent implements OnInit, OnChanges {
let matchedCountry = mainCountry ? mainCountry.iso2 : undefined;

/*
Iterate over each secondary country and check if nationalNumber starts with any of areaCodes available.
If no matches found, fallback to the main country.
*/
Iterate over each secondary country and check if nationalNumber starts with any of areaCodes available.
If no matches found, fallback to the main country.
*/
secondaryCountries.forEach(country => {
// @ts-ignore
country.areaCodes.forEach(areaCode => {
Expand Down

0 comments on commit 6af8dfb

Please sign in to comment.