Conversation
This has several bugs, and might not be the approach that we go with. But you can now drag the entire block for some blocks, like text and "meta" blocks.
There were several errors, so address those here.
The only conflict was in: with-amp-story-settings.js Retain edits in both branches.
Much of the styling in edit.css applied to the drag handle, which is removed.
On dragging, the browser creates an image of the target, for example, the entire text block. But there's already a clone below that's rotated in case the block is rotated, and this can create a non-rotated duplicate of that. So override this with an empty image.
It looks like images normally appear to drag in HTML, though not all images can drop. This caused a duplicate image to appear. So set the image to *-user-drag: none. This isn't the last bugfix needed for dragging the image block.
Before, the <StoryBlockMover> wrapped almost the entire markup of the edit component. This seemed to create issues where resizing seemed to also drag. So instead, nest the <StoryBlockMover> inside the rotating and resizing elements.
Some files were modified in the latest commits, so note that here.
| * So override this with an empty image. | ||
| */ | ||
| const dragImage = new Image(); | ||
| event.dataTransfer.setDragImage( dragImage, 0, 0 ); |
There was a problem hiding this comment.
This workaround might need more thought, but at least it prevents a duplicate, non-rotated image on dragging.
|
Known Issues Pending approval of this PR's approach, I could work on these issues: |
|
Request For Review Hi @swissspidy and @miina, There are known issues above, and possibly more bugs. I could work on those if you agree on the overall approach here. Overall, dragging the entire block is working pretty well. The main exception I found was the text block. Thanks! |
| draggable | ||
| > | ||
| { icon } | ||
| { children } |
There was a problem hiding this comment.
This <BlockDragArea> now wraps the block (children), instead of appearing alongside it. This allows dragging the entire block.
|
@kienstra It might be a good thing that text block is only draggable from edges, this will keep the functionality of selecting text for bold and italic. We might just need to figure out how to have the draggable area larger so that mainly only the area covered by Text wouldn't be draggable. |
|
@kienstra Looks like there is very few room between the edges of the Text block input and the edge of the block, we should probably figure out a way which would be the best option for keeping the bold and italic functionality as it is right now, and at the same time leaving more room for dragging. Perhaps just adding some kind of padding to the block (not the input) could work. A few other notes:
Generally the approach looks good to me! |
| height: 100%; | ||
| object-fit: cover; | ||
| /* Prevents dragging the image itself, as its container is draggable. */ | ||
| -webkit-user-drag: none; |
There was a problem hiding this comment.
Pretty sure that only -webkit-user-drag exists nowadays. The other properties either never existed (because it was never in the spec) or are simply irrelevant.
There was a problem hiding this comment.
Thanks, good point.
There was a problem hiding this comment.
cae00b7 removes these properties. You're right, I can't find any reference to them with quick searches.
Regarding movable text blocks, I feel like we should try a different route here. While in a regular post it makes sense to be able to select and format some text without selecting a block first, I don't think that necessarily applies to the stories editor as well. My immediate suggestion after comparing with other tools like Snapchat and Instagram would be this:
This is kinda similar to what's currently being worked on upstream in WordPress/gutenberg#15537, where an inner block is only selected after selecting the parent block first. tl;dr: First click -> select block, dragging possible. Second click -> edit text, no dragging With that being said, before we add any changes here, I want everyone to try the current state of this PR first. Then we can incorporate this feedback appropriately. |
|
@swissspidy I think text block dragging behaviour should as implemented in this PR with the addition of i.e. I don't think users should have to click twice in order to edit text as you suggested (click to select element + click to edit). |
As Pascal mentioned, it looks like these don't actually exist.
As suggested on the PR, add this, but change it back to the default for the editable area of text on the Text block
|
Hi @miina,
Good idea, ef75b10 shows the drag handle. I couldn't figure out a way to add padding within the Text block, so that the drag handle would display more. For example, with: .wp-block[data-type="amp/amp-story-text"] [draggable="true"] {
padding: 5px;
}the front-end display is a little too far to the left:
Thanks, I didn't notice that before. I'll work on extending the drag zone. |
|
Hi @swissspidy,
Thanks, ef75b10 uses your idea of |
As Miina mentioned, this was originally intended to be only for the handle on the left. Now, dragging from the right of a block is more limited. Still, I'm not sure if this is the right amount to change it, or if this is the right value to change.
Ensures that inner elements of meta blocks always use the full height. That way one use the full occupied area for dragging and text is propperly vertically centered when using amp-fit-text.
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
swissspidy
left a comment
There was a problem hiding this comment.
I think this is a good solution for now.
| */ | ||
| componentDidMount() { | ||
| document.querySelectorAll( '.block-editor-block-list__block[data-type="core/image"] img' ).forEach( ( image ) => { | ||
| image.setAttribute( 'draggable', 'false' ); |
There was a problem hiding this comment.
Not critical but I wonder if there's a better place for doing this -- it seems to do the same for every Draggable and each time for all the images.
|
Some notes from testing:
@swissspidy Do you think that any of these are critical? |
|
@miina Not critical, but also rather easy to fix/improve. The behavior for the list and preformatted blocks is quite the same. The drag handle is always shown and in my experience always works - unless you're precisely hovering over the text itself (because the browser would start text selection). Here's what they look like in the DOM: Instead of the
Will update the CSS there 👍 |
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
|
@miina Just pushed some commits that already improve the drag handling for these core blocks quite a bit. |
|
Thanks, @swissspidy, better now! 👍 I'm still seeing this with the list block, is it different for you? Basically it doesn't seem to be draggable from the upper part of the block. Perhaps it's OK for now since it's quite close to the text, however, wondering if it would need similar handling to the Text block 🤷♀ |
|
@miina Yup, that's the margin/padding situation I mentioned. Pushed a commit now that improves this a bit for the list block. We can revisit and fine-tune in the future. |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |










pointer: cursor, especially in the Text blockUpdate: dragging the image block works better now

Closes #2275