mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-23 06:33:06 +00:00
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:
parent
38c310a1db
commit
0b6843eb80
3 changed files with 2 additions and 4 deletions
|
|
@ -101,8 +101,6 @@ export const CampaignHeaderFilterPopover = ({
|
||||||
const filteredRows = needle
|
const filteredRows = needle
|
||||||
? searchIndex.filter((entry) => entry.haystack.includes(needle)).map((entry) => entry.row)
|
? searchIndex.filter((entry) => entry.haystack.includes(needle)).map((entry) => entry.row)
|
||||||
: optionRows
|
: 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 } =
|
const { ordered: visibleRows, selectedCount } =
|
||||||
open && isMultiSelect
|
open && isMultiSelect
|
||||||
? orderFilterOptionsSelectedFirst(filteredRows, selectionSnapshot)
|
? orderFilterOptionsSelectedFirst(filteredRows, selectionSnapshot)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ export const CampaignMobileMultiFilterField = ({
|
||||||
// No snapshot: the NativeSelect closes on every choice, so the next open
|
// No snapshot: the NativeSelect closes on every choice, so the next open
|
||||||
// already wants the just-toggled value at the top.
|
// already wants the just-toggled value at the top.
|
||||||
const { ordered } = orderFilterOptionsSelectedFirst(options, selected)
|
const { ordered } = orderFilterOptionsSelectedFirst(options, selected)
|
||||||
|
const selectedSet = new Set(selected)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Field>
|
<Field>
|
||||||
|
|
@ -44,7 +45,7 @@ export const CampaignMobileMultiFilterField = ({
|
||||||
</NativeSelectOption>
|
</NativeSelectOption>
|
||||||
{ordered.map((option) => (
|
{ordered.map((option) => (
|
||||||
<NativeSelectOption key={option.value} value={option.value}>
|
<NativeSelectOption key={option.value} value={option.value}>
|
||||||
{selected.includes(option.value) ? `✓ ${option.label}` : option.label}
|
{selectedSet.has(option.value) ? `✓ ${option.label}` : option.label}
|
||||||
</NativeSelectOption>
|
</NativeSelectOption>
|
||||||
))}
|
))}
|
||||||
</NativeSelect>
|
</NativeSelect>
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,6 @@ describe('CampaignHeaderFilterPopover selected-first ordering', () => {
|
||||||
target: { value: 'o' },
|
target: { value: 'o' },
|
||||||
})
|
})
|
||||||
|
|
||||||
// Echo / Foxtrot / Golf / Hotel match "o"; selected (Hotel, Foxtrot) first.
|
|
||||||
expect(labelsInOrder(optionNav())).toEqual(['Foxtrot', 'Hotel', 'Echo', 'Golf'])
|
expect(labelsInOrder(optionNav())).toEqual(['Foxtrot', 'Hotel', 'Echo', 'Golf'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue