Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/dataviews/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@
- DataForm: make the card layout borderless. [#72514](https://github.com/WordPress/gutenberg/pull/72514)
- DataViews: Simplify the view config properties section. [#73064](https://github.com/WordPress/gutenberg/pull/73064)
- DataViews: Add a contextual menu to the table layout header. [#73104](https://github.com/WordPress/gutenberg/pull/73104)
- DataViews: Group DataViews actions based on primary actions and regular actions and adds a separator between the groups. [#72866](https://github.com/WordPress/gutenberg/pull/72866)

### Bug fixes

- useFormValidity: make it work with any level of nesting in the form. [#72588](https://github.com/WordPress/gutenberg/pull/72588)
- Fix: DataViews modal actions in list layout. [#72793](https://github.com/WordPress/gutenberg/pull/72793)
- Fix: DataViews consistently opens filter section on clicking Add Filter via column header. [#72998](https://github.com/WordPress/gutenberg/pull/72998)
- Fix: Incorrect aria-label in table layout when items are not clickable. [#73034](https://github.com/WordPress/gutenberg/pull/73034)
- Fix: Table layout column spacing. [#72969](https://github.com/WordPress/gutenberg/pull/72969)

### Enhancements

- DataViews: Group DataViews actions based on primary actions and regular actions and adds a separator between the groups. [#72866](https://github.com/WordPress/gutenberg/pull/72866)

## 10.2.0 (2025-10-29)

### Enhancements
Expand Down
16 changes: 16 additions & 0 deletions packages/dataviews/src/components/dataviews/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ function DataViews< Item >( {
}
}, [ hasPrimaryOrLockedFilters, isShowingFilter ] );

// Show filter panel when filters are added (but allow manual hiding).
const prevFiltersLengthRef = useRef( view.filters?.length || 0 );

useEffect( () => {
const currentFiltersLength = view.filters?.length || 0;

if (
currentFiltersLength > prevFiltersLengthRef.current &&
! isShowingFilter
) {
setIsShowingFilter( true );
Copy link
Contributor

@ntsekouras ntsekouras Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if a better fix would be to just call this in table column header's add filter here. WDYT @oandregal ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ntsekouras, I tried that but setting explicitly there I thought was not better, even in filter's if you log the isShowingFilter, it is correctly showing the state, but only on initial filter check even it logs true, still it does not opens the filter panel.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, updating the state in the table layout sounds better. Was there any issue with that approach, @hbhalodia ? I see the setIsShowingFilter function is already in the context, so available in the layout as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue was not something with approach, We can set that explicitly in the column header, but my concern was, it was not working on first refresh, but thereafter it was working as expected, so updating the state in column header component wouldn't be a solution just to add a fix for this and explicitly adding to that component.

I can update the PR with tha approach (it was my first approach) but then thought of this, hence changed to that.

Updating the PR with the setting state via column header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @oandregal, This is now updated, to use context within column-header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @oandregal @ntsekouras, Can you please take a look on PR. Updated it with the required changes.

Thank You 🙇,

}

prevFiltersLengthRef.current = currentFiltersLength;
}, [ view.filters, isShowingFilter ] );

// Attach scroll event listener for infinite scroll
useEffect( () => {
if ( ! view.infiniteScrollEnabled || ! containerRef.current ) {
Expand Down
Loading