From 1bc605019d36dbf780c61371efbb13cd2e986779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 14 Dec 2023 11:26:16 +0100 Subject: [PATCH] Visibility of subcomponents is controlled by filters.js --- packages/dataviews/src/filter-summary.js | 6 +----- packages/dataviews/src/filters.js | 11 ++++++++--- packages/dataviews/src/reset-filters.js | 9 --------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/dataviews/src/filter-summary.js b/packages/dataviews/src/filter-summary.js index fc0f8848f6a93..3c30c6837103a 100644 --- a/packages/dataviews/src/filter-summary.js +++ b/packages/dataviews/src/filter-summary.js @@ -13,7 +13,7 @@ import { Children, Fragment } from '@wordpress/element'; /** * Internal dependencies */ -import { OPERATOR_IN, OPERATOR_NOT_IN, LAYOUT_LIST } from './constants'; +import { OPERATOR_IN, OPERATOR_NOT_IN } from './constants'; import { unlock } from './lock-unlock'; const { @@ -73,10 +73,6 @@ function WithSeparators( { children } ) { } export default function FilterSummary( { filter, view, onChangeView } ) { - if ( view.type === LAYOUT_LIST ) { - return null; - } - const filterInView = view.filters.find( ( f ) => f.field === filter.field ); const activeElement = filter.elements.find( ( element ) => element.value === filterInView?.value diff --git a/packages/dataviews/src/filters.js b/packages/dataviews/src/filters.js index f8b1e59e8c9d1..6195eefe8fe47 100644 --- a/packages/dataviews/src/filters.js +++ b/packages/dataviews/src/filters.js @@ -4,7 +4,12 @@ import FilterSummary from './filter-summary'; import AddFilter from './add-filter'; import ResetFilters from './reset-filters'; -import { ENUMERATION_TYPE, OPERATOR_IN, OPERATOR_NOT_IN } from './constants'; +import { + ENUMERATION_TYPE, + OPERATOR_IN, + OPERATOR_NOT_IN, + LAYOUT_LIST, +} from './constants'; const sanitizeOperators = ( field ) => { let operators = field.filterBy?.operators; @@ -57,7 +62,7 @@ export default function Filters( { fields, view, onChangeView } ) { const filterComponents = [ addFilter, ...filters.map( ( filter ) => { - if ( ! filter.isVisible ) { + if ( ! filter.isVisible || view.type === LAYOUT_LIST ) { return null; } @@ -72,7 +77,7 @@ export default function Filters( { fields, view, onChangeView } ) { } ), ]; - if ( filterComponents.length > 1 ) { + if ( filterComponents.length > 1 && view.type !== LAYOUT_LIST ) { filterComponents.push( { - if ( view.type === LAYOUT_LIST ) { - return null; - } - return (