Polish selected-first filter shells after simplify.

Drop redundant comments, use a Set for mobile checkmarks, and keep behavior unchanged.
This commit is contained in:
Francisco Ignácio Fontoura Solla 2026-07-28 18:37:04 -03:00
parent 38c310a1db
commit 0b6843eb80
3 changed files with 2 additions and 4 deletions

View file

@ -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)

View file

@ -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 (
<Field>
@ -44,7 +45,7 @@ export const CampaignMobileMultiFilterField = ({
</NativeSelectOption>
{ordered.map((option) => (
<NativeSelectOption key={option.value} value={option.value}>
{selected.includes(option.value) ? `✓ ${option.label}` : option.label}
{selectedSet.has(option.value) ? `✓ ${option.label}` : option.label}
</NativeSelectOption>
))}
</NativeSelect>

View file

@ -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'])
})