Skip to content

Commit

Permalink
Search filter cannot be enabled as a fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Oct 13, 2023
1 parent 93508c5 commit 0d68580
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions packages/edit-site/src/components/dataviews/view-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ function HeaderMenu( { dataView, header } ) {
);
const isSortable = !! header.column.getCanSort();
const isHidable = !! header.column.getCanHide();
const isFilterable = !! header.column.getCanFilter();
const isFilterableByInFilter =
const hasInFilter =
header.column.columnDef.setList &&
header.column.columnDef.setList.length > 0 &&
header.column.columnDef.filters.in;
const isFilterableByNotInFilter =
header.column.columnDef?.filters?.in;
const hasNotInFilter =
header.column.columnDef.setList &&
header.column.columnDef.setList.length > 0 &&
header.column.columnDef.filters.notIn;
header.column.columnDef?.filters?.notIn;
const hasSearchFilter = header.column.columnDef.filters?.search;
const isFilterable = hasInFilter || hasNotInFilter || hasSearchFilter;

if ( ! isSortable && ! isHidable && ! isFilterable ) {
return text;
Expand Down Expand Up @@ -140,16 +141,18 @@ function HeaderMenu( { dataView, header } ) {
) }
{ isFilterable && (
<DropdownMenuGroupV2>
<DropdownMenuItemV2
key={ 'filter-set' }
prefix={ <Icon icon={ search } /> }
onSelect={ () => {
// todo: implement search
} }
>
{ __( 'Search' ) }
</DropdownMenuItemV2>
{ isFilterableByInFilter && (
{ hasSearchFilter && (
<DropdownMenuItemV2
key={ 'filter-search' }
prefix={ <Icon icon={ search } /> }
onSelect={ () => {
// TODO: implement search.
} }
>
{ __( 'Search' ) }
</DropdownMenuItemV2>
) }
{ hasInFilter && (
<DropdownSubMenuV2
trigger={
<DropdownSubMenuTriggerV2>
Expand Down Expand Up @@ -188,7 +191,7 @@ function HeaderMenu( { dataView, header } ) {
) ) }
</DropdownSubMenuV2>
) }
{ isFilterableByNotInFilter && (
{ hasNotInFilter && (
<DropdownSubMenuV2
trigger={
<DropdownSubMenuTriggerV2>
Expand Down

0 comments on commit 0d68580

Please sign in to comment.