From 0b6843eb80b5c3fdcdaeed68676cb5c604491d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Ign=C3=A1cio=20Fontoura=20Solla?= Date: Tue, 28 Jul 2026 18:37:04 -0300 Subject: [PATCH] Polish selected-first filter shells after simplify. Drop redundant comments, use a Set for mobile checkmarks, and keep behavior unchanged. --- src/components/campaign/shared/CampaignHeaderFilterPopover.tsx | 2 -- .../campaign/shared/CampaignMobileMultiFilterField.tsx | 3 ++- tests/unit/campaignHeaderFilterPopover.unit.spec.ts | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/campaign/shared/CampaignHeaderFilterPopover.tsx b/src/components/campaign/shared/CampaignHeaderFilterPopover.tsx index 0c9dcfda..c2a67c8f 100644 --- a/src/components/campaign/shared/CampaignHeaderFilterPopover.tsx +++ b/src/components/campaign/shared/CampaignHeaderFilterPopover.tsx @@ -101,8 +101,6 @@ export const CampaignHeaderFilterPopover = ({ const filteredRows = needle ? searchIndex.filter((entry) => entry.haystack.includes(needle)).map((entry) => entry.row) : optionRows - // Order only while open: a closed popover keeps the natural facet order, and - // the snapshot is irrelevant until the next open. const { ordered: visibleRows, selectedCount } = open && isMultiSelect ? orderFilterOptionsSelectedFirst(filteredRows, selectionSnapshot) diff --git a/src/components/campaign/shared/CampaignMobileMultiFilterField.tsx b/src/components/campaign/shared/CampaignMobileMultiFilterField.tsx index 800a408d..db8bc440 100644 --- a/src/components/campaign/shared/CampaignMobileMultiFilterField.tsx +++ b/src/components/campaign/shared/CampaignMobileMultiFilterField.tsx @@ -27,6 +27,7 @@ export const CampaignMobileMultiFilterField = ({ // No snapshot: the NativeSelect closes on every choice, so the next open // already wants the just-toggled value at the top. const { ordered } = orderFilterOptionsSelectedFirst(options, selected) + const selectedSet = new Set(selected) return ( @@ -44,7 +45,7 @@ export const CampaignMobileMultiFilterField = ({ {ordered.map((option) => ( - {selected.includes(option.value) ? `✓ ${option.label}` : option.label} + {selectedSet.has(option.value) ? `✓ ${option.label}` : option.label} ))} diff --git a/tests/unit/campaignHeaderFilterPopover.unit.spec.ts b/tests/unit/campaignHeaderFilterPopover.unit.spec.ts index f381b759..ed04d0af 100644 --- a/tests/unit/campaignHeaderFilterPopover.unit.spec.ts +++ b/tests/unit/campaignHeaderFilterPopover.unit.spec.ts @@ -176,7 +176,6 @@ describe('CampaignHeaderFilterPopover selected-first ordering', () => { target: { value: 'o' }, }) - // Echo / Foxtrot / Golf / Hotel match "o"; selected (Hotel, Foxtrot) first. expect(labelsInOrder(optionNav())).toEqual(['Foxtrot', 'Hotel', 'Echo', 'Golf']) })