Skip to content

Commit

Permalink
Suggestion: Let ResetFilter ignore undefined filters
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf committed Jan 29, 2024
1 parent 8d481a3 commit 53fc637
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/dataviews/src/reset-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

function hasActiveFilters( view ) {
return (
view.search !== '' ||
view.filters?.some( ( { value } ) => value !== undefined )
);
}

export default function ResetFilter( { view, onChangeView } ) {
return (
<Button
disabled={ view.search === '' && view.filters?.length === 0 }
disabled={ ! hasActiveFilters( view ) }
__experimentalIsFocusable
size="compact"
variant="tertiary"
Expand Down

0 comments on commit 53fc637

Please sign in to comment.