diff --git a/frontend/app/src/people/utils/__tests__/filterValidation.spec.ts b/frontend/app/src/people/utils/__tests__/filterValidation.spec.ts index f1051b8e7..321026833 100644 --- a/frontend/app/src/people/utils/__tests__/filterValidation.spec.ts +++ b/frontend/app/src/people/utils/__tests__/filterValidation.spec.ts @@ -27,7 +27,7 @@ describe('testing filters', () => { describe('bountyHeaderLanguageFilter', () => { test('match', () => { expect(bountyHeaderLanguageFilter(['Javascript', 'Python'], { Javascript: true })).toEqual( - false + true ); }); test('no-match', () => { diff --git a/frontend/app/src/people/utils/filterValidation.ts b/frontend/app/src/people/utils/filterValidation.ts index e9558665d..63a0d9eab 100644 --- a/frontend/app/src/people/utils/filterValidation.ts +++ b/frontend/app/src/people/utils/filterValidation.ts @@ -35,7 +35,15 @@ export const bountyHeaderFilter = ( }; export const bountyHeaderLanguageFilter = (codingLanguage: any, filterLanguage: any) => { - if (Object.keys(filterLanguage)?.every((key: any) => !filterLanguage[key])) { - return true; - } else return codingLanguage?.some(({ value }: any) => filterLanguage[value]) ?? false; + const selectedLanguages: string[] = Object.keys(filterLanguage).filter( + (key: string) => filterLanguage[key] + ); + if (!Array.isArray(selectedLanguages) || selectedLanguages.length === 0) { + return true; // No filter selected, show all bounties + } else { + // Use "and" logic - all selected skills must match- thus using every + return selectedLanguages.every((selectedLanguage: string) => + codingLanguage.includes(selectedLanguage) + ); + } }; diff --git a/frontend/app/src/people/widgetViews/WidgetSwitchViewer.tsx b/frontend/app/src/people/widgetViews/WidgetSwitchViewer.tsx index 25ce34221..f0da4a0d6 100644 --- a/frontend/app/src/people/widgetViews/WidgetSwitchViewer.tsx +++ b/frontend/app/src/people/widgetViews/WidgetSwitchViewer.tsx @@ -108,7 +108,7 @@ function WidgetSwitchViewer(props: any) { const value = { ...body }; return ( bountyHeaderFilter(props?.checkboxIdToSelectedMap, value?.paid, !!value?.assignee) && - bountyHeaderLanguageFilter(value?.codingLanguage, props?.checkboxIdToSelectedMapLanguage) + bountyHeaderLanguageFilter(value?.coding_languages, props?.checkboxIdToSelectedMapLanguage) ); });