-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
taxonomy
data in core
store doesn't get invalidated when new terms get added
#34013
Comments
Thanks for reporting. I don't think this is a bug, but how the system works. A page refresh isn't required. What's happening is that when creating a new category, the entity cache is invalidated. Because of that, when using Once that completes the store is updated and calling |
@talldan it never gets resolved automatically , I ran |
@talldan I am reopening this issue since I can also replicate that the store never seems to get invalidated. I tested this via a import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
const terms = useSelect( (select) => {
return select(coreStore).getEntityRecords( 'taxonomy', 'category' );
} ): Expected resultAfter adding new categories at some point the newly added category should show up here. Actual resultThe new category never shows up. Even with manually trying to select the categories via the browser console. |
taxonomy
data in core
store doesn't get invalidated when new terms get added
It appears that new teams get created here: gutenberg/packages/editor/src/components/post-taxonomies/flat-term-selector.js Lines 58 to 74 in 8c68626
via an |
I believe this is pretty much what @Mamaduka mentioned here: #11700 (comment) and similarly here: #47746 I tried manually calling the
CleanShot.2023-02-23.at.12.06.13.mp4 |
@Mamaduka can you share an example of how one would invalidate an entire suite of selectors simultaneously? The issue I am currently running into when trying to solve this, is that when I invalidate Ideally, I would want to invalidate all responses for that particular taxonomy 🤔 |
@fabiankaegy, I don't believe it's currently possible to do that. There's the I think we need to update the |
This was resolved in #50952. |
Is there an existing issue for this?
Have you tried deactivating all plugins except Gutenberg?
Have you tried replicating the bug using a default theme e.g. Twenty Twenty?
Description
I ran
in console so i get the current categories in array which is fine . but when i add another category inside the editor it gets added in the backend and also in the category drop down but it doesn't update the wp.data redux store automatically a refresh is required.
I also tried useSelect and subscribe in the code but got the same result as the
wp.data
store isn't updatedStep-by-step reproduction instructions
wp.data.select("core").getEntityRecords("taxonomy", "category")
wp.data.select("core").getEntityRecords("taxonomy", "category")
again ull see the new category isnt added to the store even if you hit update button.Expected Behavior
Data with the newer categories added in wp.data redux store
Current Behavior
Refresh is required to get the new categories ( make need to add subscribe in the store for the changes )
Screenshots or screen recording (optional)
Video link showing this thing in action
https://www.loom.com/share/6497bce28d914e73aa6197f25dea96df
Code snippet (optional)
wp.data.select("core").getEntityRecords("taxonomy", "category")
WordPress Information
WP 5.8
Gutenberg Information
Haven't installed the gutenberg plugin just a clean WP site.
What browsers are you seeing the problem on?
No response
Device Information
Desktop
Operating System Information
Tested on Ubuntu LTS 20.4
The text was updated successfully, but these errors were encountered: