-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Code quality: Find a flexible way to use stores that aren't always available #32842
Comments
A few thoughts
I think the main important thing here is to consider the current usage one by one and check the "meaning" of the dependency and check its conceptual impact. |
Another thought, their block variations are now registered server side with (i think) all the information necessary for this. We could probably replace this dependency with something like Edit - ah but that server side variation registration doesn't work with all WP versions we support, so the areas would be limited to the variation fallbacks defined in javascript. This may be acceptable? |
Copying my pondering from #39987: could dynamic // This will either be the store or null.
const editorStore = await import('@wordpress/editor')
.then(result => result.store)
.catch(_err => null) @youknowriad With regard to the Table of Contents block, one use-case I wanted to eventually cover was adding a ToC to your site's Post template, without having it in the post content itself. This was back when the block relied heavily on dynamic rendering, though. I'm not sure if such a thing is still feasible given the current static implementation of #29739, though recent discussions may be moving the block back in a dynamic direction. The main issue to tackle would be getting the blocks inside the Post Content... from outside of the Post Content. So I'm not sure if that particular use case will truly end up being post-editor-only or not. If it does, the solution would be to move it to the |
This should be possible (you can get the blocks like we do in the "post content" block) and it should work (at least in the "edit" of the block. and yeah, it should be rendered dynamically if that's what we want to do.
I don't think there needs to be a dependency to "editor" to solve the issue here ( |
Description
We replaced hardcoded store keys with imported store definitions with #27088 and all related PRs. However, there are still several places where we have hardcoded store names, but they require some architectural changes because the stores used in the code are present conditionally depending on the execution context.
There is a group of items to look at raised for the code used with native mobile apps covered in #27751 issue.
In the web part of the universe, we still have two places that need more work:
Discovered in #32801:
gutenberg/packages/block-library/src/calendar/edit.js
Lines 51 to 55 in ee69822
Discovered in #32537
gutenberg/packages/server-side-render/src/index.js
Lines 19 to 23 in 58aab25
There are more places that require a fix as updated in #32866. It's related to the following core blocks:
My initial thought is that we should seek a way to consuming the data through block context. Although, it isn't clear how that could look in practice. I would start exploration with learning what shared data is available in PHP like the
$post
object or all the information that helps to decide what type of posts should be displayed on a given page. At least for the two cases referenced in this issue, the only data that is necessary can be retrieved from the currently edited$post
object.The text was updated successfully, but these errors were encountered: