Skip to content
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

Sub registry stores don't use store plugins #24542

Open
johngodley opened this issue Aug 13, 2020 · 4 comments
Open

Sub registry stores don't use store plugins #24542

johngodley opened this issue Aug 13, 2020 · 4 comments
Labels
[Package] Core data /packages/core-data [Type] Bug An existing feature does not function as intended [Type] Question Questions about the design or development of the editor.

Comments

@johngodley
Copy link
Contributor

When Gutenberg is loaded there is a bit of PHP inserted code that sets up the core stores to use the persistence plugin.

wp.data.use( wp.data.plugins.persistence )

This works fine for the core editor, and is used to get data from localStorage that is then used for insertUsage to determine the order of blocks in the block inserter.

If you use <BlockEditorProvider> outside of the full editor (for example, the Gutenberg playground) and you try and use the useSubRegistry option to get a separate registry then it doesn't use the persistence plugin as it is a new registry and the plugin hasn't been applied.

This means withRegistryProvider (which <BlockEditorProvider> uses) creates a new core/block-editor store without persistence, and this results in the insertUsage settings not being used in any editor that sits inside the provider.

Ideally if you use useSubRegistry then it should behave the same as the main registry, and any plugins should be copied across. Failing that, withRegistryProvider should have a way to enable the plugins to be applied.

However, after reading the comments in registry.js it seems that use and store plugins are deprecated anyway. I don't know what the intention is with the persistence plugin, and what the replacement will be, and if useSubRegistry will even continue being supported.

As such I've labelled this as a 'question bug' as I'm not quite sure where it fits.

@johngodley johngodley added [Type] Bug An existing feature does not function as intended [Type] Question Questions about the design or development of the editor. [Package] Core data /packages/core-data labels Aug 13, 2020
@kathrynwp kathrynwp added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 2, 2022
@kathrynwp
Copy link

Hi @johngodley is this something you'd be able to take a peek at again to see whether it's still an issue with the current versions of WordPress and Gutenberg? Thanks!

@Mamaduka
Copy link
Member

@talldan, do you know if this issue is still valid after recent persistent store refactoring?

@jordesign
Copy link
Contributor

Just a double check with @johngodley and/or @talldan to see if this issue is still relevant. I'll close in 2 weeks if we don't hear otherwise.

@jordesign jordesign removed the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Oct 26, 2023
@talldan
Copy link
Contributor

talldan commented Oct 30, 2023

@talldan, do you know if this issue is still valid after recent persistent store refactoring?

It shouldn't be an issue, though insertUsage is still using the old persistence plugin system. #39632 will migrate it to use the preferences package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Core data /packages/core-data [Type] Bug An existing feature does not function as intended [Type] Question Questions about the design or development of the editor.
Projects
None yet
Development

No branches or pull requests

5 participants