Repository navigation
Themes: Fix stale Favorites state when switching to Feature Filters. - #16265
umeshnevase wants to merge 2 commits into
Conversation
On Appearance > Add Themes, switching between the Favorites tab and the Feature Filter drawer left the theme installer in an inconsistent state:
* A "No themes found" message from an empty Favorites result stayed visible under the Feature Filter drawer, because the `no-results` body class was only cleared when a new query started. Opening the drawer now clears it.
* Fetched favorites disappeared after opening Feature Filter and returning to Favorites. The tab queries `{ browse: 'favorites' }`, but fetching by username cached the result under `{ browse: 'favorites', user }`. The tab therefore hit the empty entry cached before a username was saved. Saving a username now drops stale cached favorites queries and uses the same request as the tab, so fetched themes are kept without a page refresh.
The Favorites username form is left unchanged, so it still shows after switching back to the tab.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
mardelnet
left a comment
There was a problem hiding this comment.
Your code changes look good to me and fix the issue.
I also noticed that the Theme Count is not updated when switching from any tab to the "Feature Filter" tab, so for example, if the counter displays "2011" in the Block Themes tab, it keeps showing "2011" when the "Feature Filter" tab is activated. In my opinion, it should be reset and go back to zero.
Something like this might work from moreFilters(): $( '.wrap .theme-count' ).text( 0 );
On Appearance > Add Themes, opening the Feature Filter drawer hides the current results but leaves their state on screen, and switching back could lose the count. * The "No themes found" message from an empty Favorites result stayed visible under the drawer, because the `no-results` body class was only cleared when a new query started. Opening the drawer now clears it. * The theme count kept showing the previous tab's total (for example 2011 from Block Themes) while no themes were shown. Opening the drawer now resets it to 0. The previous count is restored when the drawer is closed without applying a filter, including when the already-active tab is clicked, which closes the drawer without running a query.
Thank you @mardelnet for the review. |
On Appearance > Add Themes, switching between the Favorites tab and the Feature Filter drawer leaves the theme installer in a wrong state. This PR fixes two problems in
src/js/_enqueues/wp/theme.js.1. Stale "No themes found" message under Feature Filters
An empty Favorites result adds the
no-resultsclass to<body>. Opening the Feature Filter drawer doesn't run a new query, so the class is never removed, and the "No themes found. Try a different search." message stays visible under the drawer.moreFilters()now removesno-resultswhen the drawer opens.2. Fetched favorites disappear after switching tabs
The Favorites tab queries
{ browse: 'favorites' }, and the server fills in the saved username. Opening Favorites before a username is saved caches an empty result under that key. Fetching by username caches the themes under a different key,{ browse: 'favorites', user }. After opening Feature Filter and returning to Favorites, the tab hits the stale empty cache entry and shows nothing, until the page is refreshed.saveUsername()now:{ browse: 'favorites' }when a username is entered, so the fetched themes share the cache entry the tab uses.The Favorites username form behaves as before, and it shows again after switching back to the tab.
Testing instructions
wporg_favoritesuser option).Trac ticket: https://core.trac.wordpress.org/ticket/66833
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Reproducing the issue, diagnosing the causes, and drafting the fix and this description. I reviewed the changes and tested them manually in the browser.
After Fix:
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.