diff --git a/packages/manager/.changeset/pr-9971-fixed-1701887926900.md b/packages/manager/.changeset/pr-9971-fixed-1701887926900.md new file mode 100644 index 00000000000..b0e88d589d9 --- /dev/null +++ b/packages/manager/.changeset/pr-9971-fixed-1701887926900.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Fixed +--- + +RegionSelect sorting in Firefox ([#9971](https://github.com/linode/manager/pull/9971)) diff --git a/packages/manager/src/components/RegionSelect/RegionSelect.utils.test.tsx b/packages/manager/src/components/RegionSelect/RegionSelect.utils.test.tsx index 2540df5db88..57359016ddd 100644 --- a/packages/manager/src/components/RegionSelect/RegionSelect.utils.test.tsx +++ b/packages/manager/src/components/RegionSelect/RegionSelect.utils.test.tsx @@ -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', @@ -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)', diff --git a/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts b/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts index 6ae57803d9e..ad6ff2d6f62 100644 --- a/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts +++ b/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts @@ -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; }); };