-
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
Add state for storing dragged block client ids to block-editor store #24782
Add state for storing dragged block client ids to block-editor store #24782
Conversation
Size Change: +99 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
* | ||
* @param {Object} state Global application state. | ||
* | ||
* @return {string[]} Array of dragged block client ids. |
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 could return null
if not dragging blocks. Should we return []
or null
in this case? :🤔. I feel like []
would be simpler to indicate that there's no blocks being dragged, and unify the type. We just have to check the length
attribute in isDraggingBlocks
.
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.
Yep, makes sense, fixed in 680714b 👍
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.
Nothing breaks code looks good. Left a question.
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.
Other than the small nitpicking, others LGTM 👍
… block-editor store
Co-authored-by: Kai Hao <kevin830726@gmail.com>
91d2892
to
fd9ef54
Compare
Description
Adds state for storing dragged client ids to block editor store.
This is used in the PR for List View drag and drop (#23952).
In List View we need a way to determine whether a dragged block can be nested as an inner block under a parent. For normal drag and drop,
InnerBlocks
as a drop zone and handles that logic, but in List View there's no renderedInnerBlocks
component (because List View doesn't render a block'sedit
function). Storing this state allows us to do a check likecanInsertBlocks( draggedBlocks, parentClientId )
, which wasn't possible before.Beyond List View, this may also be a step towards improving drop zones in the editor canvas—the dragged block ids could be used to only show valid drop zones when dragging.
How has this been tested?
Added unit tests.
For manual testing, dragging and dropping blocks should behave the same as in
master
.Types of changes
Non-breaking new API
Checklist: