-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Block editor: new blockEditor.useBlockProps
filter
#48884
Conversation
<BlockListBlock | ||
{ ...props } | ||
__unstableLayoutClassNames={ layoutClassNames } | ||
/> |
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.
To do: use the new filter here too.
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 maybe needs to be a useInnerBlocksProps
instead of a useBlockProps
filter.
Size Change: +61 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
isPartOfSelection: isSelected || isPartOfMultiSelection, | ||
adjustScrolling: | ||
isSelected || isFirstMultiSelectedBlock( clientId ), | ||
enableAnimation: | ||
! isTyping() && | ||
getGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD, | ||
blockType: _blockType, | ||
attributes: _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.
Maybe we should use context for this, I'm not sure what's best for performance.
b9f2242
to
704f13a
Compare
@@ -147,9 +152,16 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) { | |||
); | |||
} | |||
|
|||
const filteredWrapperProps = applyFilters( |
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 approach suffers from the hooks rules errors as filters get added/removed over time. I think it's probably going to create a lot of bugs.
What?
This PR is easier to review without whitespace changes.
Similar to #48809, but for the
BlockListBlock
filter.All use cases for the
editor.BlockListBlock
function are adding block props. We should create a less powerful (and easier to use) filter specifically for adding block props. With this PR it will be possible to deprecate theeditor.BlockListBlock
filter.Some block support hooks are filtering the
getEditWrapperProps
function, we should replace those instances as well.I replaced
__unstableElementContext
with__unstableUseRootPortal
which allows block support to add SVGs and blocks styles without having to be a component. This is often linked to selectors that need to be added as block props.Why?
Simplifying the block APIs.
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast