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 ( { 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', } );