-
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
Block Editor: fix duplicate clientIds when dragging patterns #35124
Conversation
Size Change: -300 B (0%) Total Size: 1.07 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.
I checked this out locally and confirmed the issue and the fix. Dragging patterns into the editor now works as expected giving each inserted block a unique clientId.
The code also looks good to me but I will leave the approval to a code owner more familiar with the functionality :)
packages/block-editor/src/components/inserter-draggable-blocks/index.js
Outdated
Show resolved
Hide resolved
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.
That makes sense to me, Thanks for the fix. 👍
Thanks for the reviews @youknowriad @fabiankaegy ! |
Fixes #35120 where dragging patterns multiple times will insert blocks with duplicate clientIds. This isn't a problem for onClick since we explicitly clone the blocks in that case.
If we don't like the code approach here, one alternative is always cloning for the 'inserter' case since we never intend to add duplicate clientIds. (It happens to work for the inserter drag currently since it re-renders that often).
Step-by-step reproduction instructions
wp.data.select('core/block-editor').getBlocks()
Before:
CleanShot.2021-09-24.at.10.07.55.mp4
After:
CleanShot.2021-09-24.at.10.07.55.mp4