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

Allow Custom Entities to Use EntityProvider #27859

Open
spencerfinnell opened this issue Dec 22, 2020 · 5 comments
Open

Allow Custom Entities to Use EntityProvider #27859

spencerfinnell opened this issue Dec 22, 2020 · 5 comments
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience Needs Technical Feedback Needs testing from a developer perspective. [Package] Core data /packages/core-data [Type] Enhancement A suggestion for improvement.

Comments

@spencerfinnell
Copy link

Is your feature request related to a problem? Please describe.

core-data only creates context for default entities: https://github.com/WordPress/gutenberg/blob/master/packages/core-data/src/entity-provider.js#L20-L26

However, custom entities can be added with the addEntities action. These entities then not seen as valid by useEntityProp().

Describe the solution you'd like
Instead of pulling from a static list of entities, all registered entities should be given context.

Describe alternatives you've considered
Currently I have duplicated entity-provider.js and reference the local provider vs. Gutenberg's when using a custom entity.

@gziolo gziolo added [Feature] Extensibility The ability to extend blocks or the editing experience [Package] Core data /packages/core-data Needs Technical Feedback Needs testing from a developer perspective. labels Dec 22, 2020
@yoscbd
Copy link

yoscbd commented Sep 8, 2022

@ndiego
Copy link
Member

ndiego commented May 21, 2023

The solution @yoscbd provided above does work, and I have implemented my own custom entities as well. Therefore, I am going to close this out.

@ndiego ndiego closed this as completed May 21, 2023
@spencerfinnell
Copy link
Author

spencerfinnell commented May 21, 2023

Thank you for the link, however the solution linked does not address my original report (and I mention the ability to register entities with addEntities).

Yes, you can register custom entities for use by some hooks/functions, but not all.

My original issue is support for useEntityProp/EntityProvider which does not work with the technique provided above because entity context is only created for locally imported entities, not all registered entities:

...rootEntitiesConfig.reduce( ( acc, loader ) => {

@spencerfinnell
Copy link
Author

@ndiego is it possible to reopen this so it remains visible? The original report is still a reproducible issue and blocker for things like #43751 (comment)

@ndiego
Copy link
Member

ndiego commented May 25, 2023

Yes, absolutely!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience Needs Technical Feedback Needs testing from a developer perspective. [Package] Core data /packages/core-data [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants