Skip to content

Commit

Permalink
Disable filtering for server-side filtered items
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 committed Jan 28, 2021
1 parent 20937fc commit 2edd27d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ export default function ContentCategoriesMenu() {
isSearchDebouncing={ isDebouncing || ! isResolved }
>
{ search && ! isDebouncing && (
<SearchResults items={ categories } search={ search } />
<SearchResults
items={ categories }
search={ search }
noFilter
/>
) }

{ ! search &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function ContentPagesMenu() {
isSearchDebouncing={ isDebouncing || ! isResolved }
>
{ search && ! isDebouncing && (
<SearchResults items={ pages } search={ search } />
<SearchResults items={ pages } search={ search } noFilter />
) }

{ ! search &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function ContentPostsMenu() {
isSearchDebouncing={ isDebouncing || ! isResolved }
>
{ search && ! isDebouncing && (
<SearchResults items={ posts } search={ search } />
<SearchResults items={ posts } search={ search } noFilter />
) }

{ ! search && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useSelect } from '@wordpress/data';
import TemplateNavigationItem from './template-navigation-item';
import ContentNavigationItem from './content-navigation-item';

export default function SearchResults( { items, search } ) {
export default function SearchResults( { items, search, noFilter } ) {
let itemType = null;
if ( items?.length > 0 ) {
if ( items[ 0 ].taxonomy ) {
Expand Down Expand Up @@ -70,6 +70,10 @@ export default function SearchResults( { items, search } ) {
return [];
}

if ( ! noFilter ) {
return items;
}

return items.filter( ( { slug } ) => {
const { title, description } = itemInfosMap[ slug ];

Expand Down

0 comments on commit 2edd27d

Please sign in to comment.