Blocks: Use selectors to fetch details about for patterns and styles …#18398
Blocks: Use selectors to fetch details about for patterns and styles …#18398gziolo wants to merge 1 commit into
Conversation
|
To consider:
|
a985633 to
330abef
Compare
I opted for:
I can update to
I opted for using |
To clarify, I only think If we know one way or the other, we should return that known value. For what you describe, it seems like an empty array would be appropriate. |
Hmm, I wonder if this is really worthwhile then. Any time we can simply point to a reducer value, it's always going to be more optimal than trying to compute a derived result, even if that result is memoized. I dunno if there might be a middle-ground option here where we still have a Roughly: function getBlockStyles( state, blockName ) {
if ( state.blockTypes[ blockName ] ) {
return state.blockStyles[ blockName ] || EMPTY_ARRAY;
}
}Otherwise, maybe we should keep it as is it is. |
The challenge with |
| ...get( state, [ blockType.name ], [] ), | ||
| ], ( style ) => style.name ); | ||
| } ), | ||
| }; |
There was a problem hiding this comment.
I know people used to disable styles by removing them from this reducer, this won't be possible anymore with this change.
There was a problem hiding this comment.
Interesting. Thanks for sharing.
There was a problem hiding this comment.
I know people used to disable styles by removing them from this reducer, this won't be possible anymore with this change.
Can you elaborate on what you mean with this? Any links you can share with more information?
|
I'm closing this PR based on the feedback received. Thank you @youknowriad and @aduth for help. |
…from block types
Description
Based on the comment from @aduth in #18270 (comment):
This should also fix the copy and paste issues raised by @mcsf in #18270 (comment):
How has this been tested?
npm run test-unitI also tested manually in the browser by executing the following code on JS console:
and checked that this new style got properly registered for the Quote block:
Types of changes
Refactoring.
Checklist: