From 0d685803a501789fd3da96a2ae7d5677aaf3f1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Fri, 13 Oct 2023 19:40:21 +0200 Subject: [PATCH] Search filter cannot be enabled as a fallback --- .../src/components/dataviews/view-list.js | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/edit-site/src/components/dataviews/view-list.js b/packages/edit-site/src/components/dataviews/view-list.js index 2385dac471eb70..b3ac4a0d21b2cb 100644 --- a/packages/edit-site/src/components/dataviews/view-list.js +++ b/packages/edit-site/src/components/dataviews/view-list.js @@ -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; @@ -140,16 +141,18 @@ function HeaderMenu( { dataView, header } ) { ) } { isFilterable && ( - } - onSelect={ () => { - // todo: implement search - } } - > - { __( 'Search' ) } - - { isFilterableByInFilter && ( + { hasSearchFilter && ( + } + onSelect={ () => { + // TODO: implement search. + } } + > + { __( 'Search' ) } + + ) } + { hasInFilter && ( @@ -188,7 +191,7 @@ function HeaderMenu( { dataView, header } ) { ) ) } ) } - { isFilterableByNotInFilter && ( + { hasNotInFilter && (