Skip to content

Commit

Permalink
Merge pull request #9971 from abailly-akamai/M3-7533
Browse files Browse the repository at this point in the history
fix: [M3-7533] - RegionSelect sorting in Firefox
  • Loading branch information
abailly-akamai authored Dec 7, 2023
2 parents 188cacf + 9a58722 commit d6a9890
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-9971-fixed-1701887926900.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

RegionSelect sorting in Firefox ([#9971](https://github.com/linode/manager/pull/9971))
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ const regions: Region[] = [
];

const expectedRegions: RegionSelectOption[] = [
{
data: { country: 'ca', region: 'North America' },
label: 'CA Location (ca-1)',
unavailable: false,
value: 'ca-1',
},
{
data: {
country: 'us',
Expand All @@ -53,6 +47,12 @@ const expectedRegions: RegionSelectOption[] = [
unavailable: false,
value: 'us-1',
},
{
data: { country: 'ca', region: 'North America' },
label: 'CA Location (ca-1)',
unavailable: false,
value: 'ca-1',
},
{
data: { country: 'jp', region: 'Asia' },
label: 'JP Location (jp-1)',
Expand Down
13 changes: 11 additions & 2 deletions packages/manager/src/components/RegionSelect/RegionSelect.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,20 @@ export const getRegionOptions = ({
return 1;
}

// If regions are in the same group, sort alphabetically by label
// Then we group by country
if (region1.data.country < region2.data.country) {
return 1;
}
if (region1.data.country > region2.data.country) {
return -1;
}

// If regions are in the same group or country, sort alphabetically by label
if (region1.label < region2.label) {
return -1;
}
return 0;

return 1;
});
};

Expand Down

0 comments on commit d6a9890

Please sign in to comment.