-
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
Blocks: Use selectors to fetch details about for patterns and styles … #18398
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Thanks for sharing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-unit
I 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: