From 82b508ca4e16156479987dff13dac175adb7bb2c Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Wed, 6 Dec 2023 13:29:01 -0500 Subject: [PATCH 1/4] Fix RegionSelect sorting in Firefox --- .../manager/src/components/RegionSelect/RegionSelect.utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts b/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts index 6ae57803d9e..a482470c0b9 100644 --- a/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts +++ b/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts @@ -77,7 +77,8 @@ export const getRegionOptions = ({ if (region1.label < region2.label) { return -1; } - return 0; + + return 1; }); }; From c501837e2e2649354cf2a9da9e7c633835d8d57a Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Wed, 6 Dec 2023 13:38:47 -0500 Subject: [PATCH 2/4] Added changeset: RegionSelect sorting in Firefox --- packages/manager/.changeset/pr-9971-fixed-1701887926900.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/manager/.changeset/pr-9971-fixed-1701887926900.md 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)) From 3f0115e8a7a79632e60d13d3de18a327e888a1ab Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Wed, 6 Dec 2023 17:35:31 -0500 Subject: [PATCH 3/4] Handle country grouping --- .../src/components/RegionSelect/RegionSelect.utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts b/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts index a482470c0b9..ad6ff2d6f62 100644 --- a/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts +++ b/packages/manager/src/components/RegionSelect/RegionSelect.utils.ts @@ -73,7 +73,15 @@ 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; } From 9a58722820a75b7a95f8c0e905941788de526fd0 Mon Sep 17 00:00:00 2001 From: Alban Bailly Date: Thu, 7 Dec 2023 09:14:12 -0500 Subject: [PATCH 4/4] Fix test --- .../RegionSelect/RegionSelect.utils.test.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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)',