-
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
Remove ifBlockEditSelected internal higher-order component #22905
Conversation
Size Change: +464 B (0%) Total Size: 1.12 MB
ℹ️ View Unchanged
|
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.
Makes sense, good memories from old times when HOCs were cool :)
The end-to-end tests illustrate a legitimate issue, which is that the previous implementation would pass along
It could depend on a few things:
|
I think we should just pass |
Updated in e6e03c9 to pass only |
The only place where props are passed to
It doesn't look like there is anything passed down really. It looks not needed. I agree that using |
This pull request seeks to remove the
ifBlockEditSelected
internal helper of the@wordpress/block-editor
package. The motivation here is (a) to flatten the common block React element hierarchy and (b) to favor hooks-based implementations over higher-order components.ifBlockEditSelected
was a useful and expressive helper at the time it was originally implemented, due to the cumbersome nature of using React Context<Consumer>
elements. WithuseContext
, it's much simpler now to get direct access to the context object properties relevant for this behavior. For some affected components, it's arguably still more verbose than the previous implementation, but it seems like a reasonable compromise. A flattened element hierarchy may bring some improved performance and debugging benefit.Testing Instructions:
Verify no regressions in the behavior of affected components. For example, block toolbar and inspector controls should only appear for the selected block.