diff --git a/frontend/src/component/common/FilterDateItem/FilterDateItem.tsx b/frontend/src/component/common/FilterDateItem/FilterDateItem.tsx index c40d3ed6c3..85629e89b7 100644 --- a/frontend/src/component/common/FilterDateItem/FilterDateItem.tsx +++ b/frontend/src/component/common/FilterDateItem/FilterDateItem.tsx @@ -72,7 +72,7 @@ export const FilterDateItem: FC = ({ { const recordedChanges = setup(mockState); - const valuesElement = await screen.findByText('1, 3'); + const valuesElement = await screen.findByText('Option 1, Option 3'); await screen.findByText('is any of'); expect(valuesElement).toBeInTheDocument(); @@ -83,7 +83,7 @@ describe('FilterItem Component', () => { const recordedChanges = setup(mockState); - const valuesElement = await screen.findByText('1, 3 +1'); + const valuesElement = await screen.findByText('Option 1, Option 3 +1'); await screen.findByText('is any of'); expect(valuesElement).toBeInTheDocument(); }); diff --git a/frontend/src/component/filter/FilterItem/FilterItem.tsx b/frontend/src/component/filter/FilterItem/FilterItem.tsx index c2a6c9dc68..6c74b61c2a 100644 --- a/frontend/src/component/filter/FilterItem/FilterItem.tsx +++ b/frontend/src/component/filter/FilterItem/FilterItem.tsx @@ -56,6 +56,9 @@ export const FilterItem: FC = ({ }; const selectedOptions = state ? state.values : []; + const selectedDisplayOptions = selectedOptions + .map((value) => options.find((option) => option.value === value)?.label) + .filter((label): label is string => label !== undefined); const currentOperator = state ? state.operator : currentOperators[0]; const onDelete = () => { @@ -99,7 +102,7 @@ export const FilterItem: FC = ({ = ({ value={searchText} onChange={(event) => setSearchText(event.target.value)} placeholder='Search' + autoFocus InputProps={{ startAdornment: ( diff --git a/frontend/src/component/filter/FilterItem/FilterItemChip/FilterItemChip.tsx b/frontend/src/component/filter/FilterItem/FilterItemChip/FilterItemChip.tsx index 2feb1e95c3..b76a10e7f4 100644 --- a/frontend/src/component/filter/FilterItem/FilterItemChip/FilterItemChip.tsx +++ b/frontend/src/component/filter/FilterItem/FilterItemChip/FilterItemChip.tsx @@ -68,7 +68,7 @@ const Arrow = () => ( interface IFilterItemChipProps { label: string; - selectedOptions?: string[]; + selectedDisplayOptions?: string[]; operatorOptions: string[]; operator: string; onChangeOperator: (value: string) => void; @@ -78,17 +78,17 @@ interface IFilterItemChipProps { export const FilterItemChip: FC = ({ label, - selectedOptions = [], + selectedDisplayOptions = [], operatorOptions, operator, onChangeOperator, onClick, onDelete, }) => { - const hasSelectedOptions = selectedOptions.length > 0; + const hasSelectedOptions = selectedDisplayOptions.length > 0; const maxExplicitOptions = 2; - const explicitOptions = selectedOptions.slice(0, maxExplicitOptions); - const remainingOptions = selectedOptions.length - maxExplicitOptions; + const explicitOptions = selectedDisplayOptions.slice(0, maxExplicitOptions); + const remainingOptions = selectedDisplayOptions.length - maxExplicitOptions; const { trackEvent } = usePlausibleTracker(); const onChange = (operator: string) => {