diff --git a/src/components/catalog.jsx b/src/components/catalog.jsx index 2fde7a3e7..2b1d33d3e 100644 --- a/src/components/catalog.jsx +++ b/src/components/catalog.jsx @@ -39,17 +39,17 @@ const Catalog = ({widgets = [], isLoading = true}) => { const [filteredWidgets, isFiltered] = useMemo(() => { let isFiltered = false - // in_catalog widgets are already being rendered via featured widgets - // append remaining widgets that are playable but not in_catalog + // create initial set of widgets to filter from - only including playable widgets let results = widgets.filter(w => { - return parseInt(w.is_playable) == 1 && parseInt(w.in_catalog) == 0 + return parseInt(w.is_playable) === 1 }) + // filters are active, only match active filters if(state.activeFilters.length){ isFiltered = true // find widgets that have all the active filters - results = widgets.filter(w => { + results = results.filter(w => { const {features, supported_data, accessibility_keyboard, accessibility_reader} = w.meta_data return state.activeFilters.every(f =>{ if (features.includes(f) || supported_data.includes(f)) return true @@ -68,6 +68,12 @@ const Catalog = ({widgets = [], isLoading = true}) => { results = results.filter(w => re.test(w.name)) } + // if there are no filters set, take out the featured widgets (those with in_catalog = 1) + // when no filter is present, a featured section appears already showing featured widgets + if (!isFiltered) { + results = results.filter(w => parseInt(w.in_catalog) !== 1) + } + return [results, isFiltered] }, [widgets, state.searchText, state.activeFilters]) @@ -262,25 +268,28 @@ const Catalog = ({widgets = [], isLoading = true}) => { className={`filter-toggle desktop-only ${state.showingFilters ? 'close-mode' : ''}`} aria-label={state.showingFilters ? 'Feature filters drawer open' : 'Filter catalog by features'} onClick={ filterLinkClickHandler }> - Feature + Feature + + Accessibility +