-
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
Zoom Out: Fix bouncy drop zones #66399
Conversation
Size Change: +1 B (0%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
Tested this and it feels much better! Some oddness I noticed (using Chrome and WP Playground to test) is that sometimes the dropzone under the header and above the footer randomly disappears: randomly.can.t.add.patterns.under.header.or.above.footer.movI'm not quite sure why it happens and can't quite replicate it clearly. Here's more of the same, along with a VERY tiny notice at the end to "drop files to upload": drop.files.to.upload.mov |
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 is so much better! Thank you for tracking this down and fixing @talldan.
For me this is a vast improvement and we should ship it and backport to 6.7.
If there's another edge case with what Anne noticed then we can circle back to that. I certainly cannot replicate it in my testing.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Infinitely better 🎉 |
Co-authored-by: Dave Smith <getdavemail@gmail.com>
I tried a few times, but it's definitely a tricky one to replicate.
Oh yep, that one's easy to reproduce using that Patton pattern. I think this is an issue with the cover block's media drop zone. I'll try to debug it, and if I can make a separate PR. |
Seems like the cover block issue is non zoom out related. You can drag any blocks into a cover block, and it seems to think blocks are files 😱 Kapture.2024-10-24.at.16.34.54.mp4 |
* Also consider child elements of insertion point in `isInsertionPoint` function * Also disable the root block list when in zoom out mode * Consider situations where the sectionRoot is also the root * Update comment Co-authored-by: Dave Smith <getdavemail@gmail.com> * Fix lint --------- Co-authored-by: talldan <talldanwp@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: annezazu <annezazu@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: colorful-tones <colorful-tones@git.wordpress.org> Co-authored-by: stokesman <presstoke@git.wordpress.org>
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: 2254850 |
// drop zones - the actual 'root' block list and the section root. | ||
return { | ||
isDropZoneDisabled: | ||
isZoomOut() && sectionRootClientId !== '', |
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've made an issue for the Cover Block problems - #66422 I'm not sure if this is something to include in the 6.7 cycle, it might be an old bug, but it is affecting Zoom Out. |
Worth a look. Thanks Dan! |
* Also consider child elements of insertion point in `isInsertionPoint` function * Also disable the root block list when in zoom out mode * Consider situations where the sectionRoot is also the root * Update comment Co-authored-by: Dave Smith <getdavemail@gmail.com> * Fix lint --------- Co-authored-by: talldan <talldanwp@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: annezazu <annezazu@git.wordpress.org> Co-authored-by: ndiego <ndiego@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: colorful-tones <colorful-tones@git.wordpress.org> Co-authored-by: stokesman <presstoke@git.wordpress.org>
What?
Fixes #65927 (or at least one of the main issues)
Why?
Block drag and drop uses the
useBlockDropZone
hook. Rather than each block being a drop zone, each block list is a drop zone.For Zoom Out, only the 'section' blocks are interactive—the only block list that's supposed to be active as a drop zone is the one represented by the
sectionRootClientId
. This is handled by theuseSelect
in theuseInnerBlocksProps
hook, it returnsisDropZoneDisabled: true
for any block lists that are not the section root, and that's used to prevent binding theuseBlockDropZone
hook.The bug - that hook has an early
if ( ! clientId )
return in theuseSelect
, which always returns a falsey for theisDropZoneDisabled
value, so in a lot of cases zoom out would accidentally have two blocks lists acting as drop zones - the actual 'root' block list and the section root.This extra drop zone causes some rogue
onDragLeave
events triggeringhideInsertionPoint
.How?
Adds some extra logic in the selector for the root block list when zoom out is active. It is valid for the sectionRoot to be the actual root, so this is checked.
Separately I've also added some extra safety to the
isInsertionPoint
check, as this only tests against the outer element and not nested elements of the insertion point.Testing Instructions
In trunk: The Insertion Points shows and hides itself as you drag between the block and the margin
In this PR: The Insertion Point stays present as you drag back and forth.
Screenshots or screencast
Before
Kapture.2024-10-21.at.18.54.34.mp4
After
Kapture.2024-10-24.at.11.17.38.mp4