Skip to content

Commit e1d2ea7

Browse files
ntsekourasMamadukajameskosteroandregalSirLouen
authored
DataViews: Fix filter toggle flickering when there are locked or primary filters (#75913) (#76068)
Co-authored-by: Mamaduka <[email protected]> Co-authored-by: jameskoster <[email protected]> Co-authored-by: oandregal <[email protected]> Co-authored-by: SirLouen <[email protected]> Co-authored-by: t-hamano <[email protected]>
1 parent d4e4afa commit e1d2ea7

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

packages/dataviews/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- DataForm: Fix focus loss when collapsing in Card view. [#75689](https://github.com/WordPress/gutenberg/pull/75689)
1313
- DataViews: Avoid flickering while refreshing. [#74572](https://github.com/WordPress/gutenberg/pull/74572)
1414
- DataViews: Fix spacing in first column. [#75693](https://github.com/WordPress/gutenberg/pull/75693)
15+
- DataViews: Fix filter toggle flickering when there are locked or primary filters. [#75913](https://github.com/WordPress/gutenberg/pull/75913)
1516
- DataViews: Remove visual divider between quick and regular actions in the actions menu. [#75893](https://github.com/WordPress/gutenberg/pull/75893)
1617
- DataForm: field label for panel layout are no longer uppercased. [#75944](https://github.com/WordPress/gutenberg/pull/75944)
1718

packages/dataviews/src/components/dataviews-filters/toggle.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ function FiltersToggle() {
3131
},
3232
[ onChangeView, setIsShowingFilter ]
3333
);
34-
const visibleFilters = filters.filter( ( filter ) => filter.isVisible );
3534

36-
const hasVisibleFilters = !! visibleFilters.length;
3735
if ( filters.length === 0 ) {
3836
return null;
3937
}
4038

39+
const hasVisibleFilters = filters.some( ( filter ) => filter.isVisible );
40+
4141
const addFilterButtonProps = {
4242
label: __( 'Add filter' ),
4343
'aria-expanded': false,
@@ -54,12 +54,19 @@ function FiltersToggle() {
5454
setIsShowingFilter( ! isShowingFilter );
5555
},
5656
};
57+
// When there are primary or locked filters, the filter bar is always
58+
// visible and cannot be hidden, so the toggle button should be disabled.
59+
const hasPrimaryOrLockedFilters = filters.some(
60+
( filter ) => filter.isPrimary || filter.isLocked
61+
);
5762
const buttonComponent = (
5863
<Button
5964
ref={ buttonRef }
6065
className="dataviews-filters__visibility-toggle"
6166
size="compact"
6267
icon={ funnel }
68+
disabled={ hasPrimaryOrLockedFilters }
69+
accessibleWhenDisabled
6370
{ ...( hasVisibleFilters
6471
? toggleFiltersButtonProps
6572
: addFilterButtonProps ) }

0 commit comments

Comments
 (0)