-
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
Avoid getBlock in block-list/block #11899
Conversation
Do you intend / have a desire to see this through before 5.0 ? I have a sense it could be quite impactful, particularly for nested blocks, which see quite a bit of unnecessary re-renders on child updates (I'd hope would not occur with the refactor?). Might go well with #12312 |
My hope is to get this as soon as possible. I'd like to measure the impact first. And yeah I think with this #12312 it seems logical to have a separate selector for the attributes. I think it's probably too late for 5.0 though but maybe good for 5.0.1 |
I'll try to rebase and measure this tomorrow. |
972b7a4
to
0d69dc8
Compare
The test failure looks legitimate:
|
const { replaceBlock } = dispatch( 'core/editor' ); | ||
export default compose( [ | ||
withSelect( ( select, { clientId } ) => ( { | ||
block: select( 'core/editor' ).getBlock( clientId ), |
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.
This looks like a good candidate for optimization when #11851 lands.
Edit: I guess it probably won't have much an impact in common usage, if the block warning is not expected to be frequently shown. I don't see any downside to standardizing on a convention of using the registry
argument if the selected prop is only used in the callback of a withDispatch
function though.
@@ -409,16 +408,18 @@ export class BlockListBlock extends Component { | |||
isParentOfSelectedBlock, | |||
isDraggable, | |||
className, | |||
blockName, | |||
isValid, |
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.
It seems odd our mixed application of "block" as a prefix in props, when in fact the isValid
is specifically referring to the validity of a block. Given that the component is "BlockListBlock", an argument could be made that the prefix is not necessary at all.
Not really a blocker.
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.
Not really a blocker.
I love it :) I think I'll update and remove the prefix (I hope I won't have eslint issues :) )
isEmptyDefaultBlock: block && isUnmodifiedDefaultBlock( block ), | ||
isPreviousBlockADefaultEmptyBlock: previousBlock && isUnmodifiedDefaultBlock( previousBlock ), | ||
isEmptyDefaultBlock: blockName && isUnmodifiedDefaultBlock( { name: blockName, attributes: blockAttributes } ), | ||
isPreviousBlockADefaultEmptyBlock: previousBlockClientId && isUnmodifiedDefaultBlock( { |
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.
My concern from #11811 (comment) still holds true here.
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.
Not strictly related to the pull request, but: Why do we care about not showing a sibling inserter if the previous block is an empty default block? I might do some separate exploring 😄
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.
This was @jasmussen's proposal I think. I also would prefer removing it if it doesn't harm UX
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.
Just to be sure I understand this correctly: this rule hides the sibling inserter between an empty paragraph block and another block?
If correct, the reasoning for removing that likely stems back to when the sibling inserter click area spanned the full width and it was way too easy to invoke it. Given recent changes to this hit area and the sibling inserter behavior itself, totally okay to revisit and see if it's a good experience.
wrapperProps = { ...wrapperProps, 'data-align': align }; | ||
|
||
return <BlockListBlock { ...props } wrapperProps={ wrapperProps } />; | ||
return <BlockListBlock { ...props } className={ "block-" + props.clientID } />; |
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.
clientID
-> clientId
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.
return { | ||
...block, | ||
attributes, | ||
attributes: getBlockAttributes( state, clientId ), |
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.
We should maybe consider revising the dependants of this selector to use getBlockAttributes.getDependants( state, clientId )
instead of listing them out again explicitly.
78c74f1
to
26c9e96
Compare
* Avoid rerending the current block if the previous block change * Always show the sibling inserter * Optimize the insertion point component (#12384)
ca7aac5
to
81c5791
Compare
23d5c70
to
cda9eef
Compare
@youknowriad @aduth I'm having issue, probably because of this update. Here's the info : #12494 . Thanks! |
isSelectionEnabled: isSelectionEnabled(), | ||
initialPosition: getSelectedBlocksInitialCaretPosition(), | ||
isEmptyDefaultBlock: | ||
name && isUnmodifiedDefaultBlock({ name, attributes }), |
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.
This auto-formatting sure did make a mess 😕 (even after "lint fixes")
Is this a breaking change for the So now I do If there are 2 3rd party actions hooked to |
@ktmn These changes are largely reverted as of #12943 (available in 5.0.2-RC2). Exposing all of the props was deemed here to be a non-intentional exposure, where the † The reason for this being that BlockListBlock is a pivotal component in the editor rendering, and is fully expected to be refactored as necessary for performance or features' sake, including adding or removing props. |
Last part to be extracted from #11811. This PR tries to make The
BlockListBlock
component more performant by avoiding the use ofgetBlock
(which is not great especially for columns blocks)