From af3cb73f6f33b7ffabd129211235c31f518c3d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:54:38 +0200 Subject: [PATCH 1/2] Have the filter toggle open if there are primary filters --- packages/dataviews/src/components/dataviews/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/dataviews/src/components/dataviews/index.tsx b/packages/dataviews/src/components/dataviews/index.tsx index 81f901f0859bbc..c8a34028d78903 100644 --- a/packages/dataviews/src/components/dataviews/index.tsx +++ b/packages/dataviews/src/components/dataviews/index.tsx @@ -71,8 +71,6 @@ export default function DataViews< Item >( { }: DataViewsProps< Item > ) { const [ selectionState, setSelectionState ] = useState< string[] >( [] ); const [ density, setDensity ] = useState< number >( 0 ); - const [ isShowingFilter, setIsShowingFilter ] = - useState< boolean >( false ); const isUncontrolled = selectionProperty === undefined || onChangeSelection === undefined; const selection = isUncontrolled ? selectionState : selectionProperty; @@ -95,6 +93,10 @@ export default function DataViews< Item >( { }, [ selection, data, getItemId ] ); const filters = useFilters( _fields, view ); + const [ isShowingFilter, setIsShowingFilter ] = useState< boolean >( () => + ( filters || [] ).some( ( filter ) => filter.isPrimary ) + ); + return ( Date: Wed, 21 Aug 2024 09:52:39 +0200 Subject: [PATCH 2/2] Update e2e test --- test/e2e/specs/site-editor/patterns.spec.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/e2e/specs/site-editor/patterns.spec.js b/test/e2e/specs/site-editor/patterns.spec.js index 538f9ba936a897..162ec15146c67e 100644 --- a/test/e2e/specs/site-editor/patterns.spec.js +++ b/test/e2e/specs/site-editor/patterns.spec.js @@ -149,13 +149,6 @@ test.describe( 'Patterns', () => { await expect( patterns.item ).toHaveCount( 3 ); - await patterns.content - .getByRole( 'button', { - name: 'Toggle filter display', - exact: true, - } ) - .click(); - const searchBox = patterns.content.getByRole( 'searchbox', { name: 'Search', } );