Skip to content

Fix DataViews filter button flickering#71674

Closed
Adi-ty wants to merge 4 commits intoWordPress:trunkfrom
Adi-ty:fix/dataviews-filter-flickering
Closed

Fix DataViews filter button flickering#71674
Adi-ty wants to merge 4 commits intoWordPress:trunkfrom
Adi-ty:fix/dataviews-filter-flickering

Conversation

@Adi-ty
Copy link
Copy Markdown
Contributor

@Adi-ty Adi-ty commented Sep 16, 2025

What?

Closes #71672

Clicking the filter button when locked filters are present causes flickering due to an infinite re-render loop.

Why?

The useEffect that auto-shows locked filters had isShowingFilter in its dependency array, creating a loop.

How?

Remove isShowingFilter from the effect dependencies. The effect should only run when hasPrimaryOrLockedFilters changes, not when the user manually toggles filter visibility.

Testing Instructions

  1. Go to Appearance > Editor > Patterns. This screen is the easiest to see the problem.
  2. Click the filter button.

Screenshots or screencast

Before After
Screen.Recording.2025-09-16.at.7.44.47.AM.mov
Screen.Recording.2025-09-16.at.7.40.21.AM.mov

Adi-ty and others added 2 commits September 16, 2025 07:43
Remove isShowingFilter from useEffect deps to break infinite re-render
loop when toggling filters with locked filters present.

Fixes WordPress#71672
Copy link
Copy Markdown
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

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

The current behavior is intentional: filters that are set as primary should always be visible, even if empty (no value set). See my comment at #71672 (comment)

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Sep 16, 2025
@Adi-ty
Copy link
Copy Markdown
Contributor Author

Adi-ty commented Sep 16, 2025

The current behavior is intentional: filters that are set as primary should always be visible, even if empty (no value set). See my comment at #71672 (comment)

Thanks for the feedback!

I've implemented a fix that disables the filter toggle button when only primary or locked filters exist.
Screenshot 2025-09-16 at 2 05 30 PM

@Adi-ty Adi-ty marked this pull request as ready for review September 16, 2025 09:02
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 16, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Adi-ty <iamadisingh@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: SirLouen <sirlouen@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@oandregal
Copy link
Copy Markdown
Member

This doesn't look great:

Screen.Recording.2025-09-30.at.10.41.07.mov

Given this only happens when all filters are either primary or locked (can't be hidden), I wonder if it'd be best to just hide the filter toggle in this scenario.

@ntsekouras
Copy link
Copy Markdown
Contributor

@Adi-ty could you rebase in order to review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataViews flickers when clicking filter button

4 participants