-
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
Improve insertion point and drag-n-drop in the widgets screen #32953
Conversation
bfe201b
to
9741301
Compare
Size Change: +1.9 kB (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
@@ -59,7 +59,7 @@ function useInsertionPoint( { | |||
let _destinationRootClientId = rootClientId; | |||
let _destinationIndex; | |||
|
|||
if ( insertionIndex ) { | |||
if ( insertionIndex !== undefined ) { |
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 line fixes #32931. If insertionIndex
is 0
then it short-circuit the logic below, which is the case when the block list is empty.
* | ||
* @return {boolean} Is dragging within the target element. | ||
*/ | ||
const useIsDraggingWithin = ( elementRef ) => { |
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 file is copy-pasted from index.js
.
@@ -1,41 +1,72 @@ | |||
$panel-title-height: 48px; |
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 probably a bad idea but I don't have other solutions for now.
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.
Great stuff, this improves dragging into those empty areas massively 🎉
packages/edit-widgets/src/blocks/widget-area/edit/inner-blocks.js
Outdated
Show resolved
Hide resolved
Quick note that I'm now seeing a hover outline around panel areas (even when not dragging). Not sure if this could be related to this PR or something else that merged recently! cc @kevin940726 panel-outline.mov |
I assume it's not intended but I like it :))) |
It's not a bug introduced in this PR and it has patch (#33015) already :), but thanks for noting! |
Description
Fix #32652, fix #32931.
Expand the size of Widget Area's
InnerBlocks
to the entire panel, so that dropping anywhere on that panel works. The trick is to use some hacky negativemargin-top
andpadding-top
combo to achieve the effects. We also have to elevate the z-index of the title element so that clicking on it still works. However, we don't wantdragenter
anddragleave
events being triggered when dragging blocks onto the title element, hence we setpointer-events: none
to the title element while dragging.The widget area now shows a ring outline when a block is dragging upon it, to compensate that the blue line indicator is still kind of buggy and not easy to fix at the time (#32880).
c.c. @critterverse for design reviews♥️ 🙇♂️ !
How has this been tested?
Screenshots
Kapture.2021-06-24.at.18.39.04.mp4
Types of changes
Bug fix
Checklist:
*.native.js
files for terms that need renaming or removal).