-
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
Input Interaction: set caret correctly on merge forward (Delete) #15599
Conversation
So if I'm reading properly, this doesn't need to be backported to WP 5.2 as the culprit PR is not included in it right? |
@youknowriad I guess you're right, if the full Gutenberg release will not be included in WordPress 5.2.1. |
It should probably still be included in the Gutenberg release. |
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.
Looks good. Works well 👍
In the course of testing this, I discovered another (unrelated) issue: #15604
const blockBType = getBlockType( blockB.name ); | ||
const { clientId, attributeKey, offset } = getSelectionStart( state ); | ||
const hasSelection = clientId === clientIdA || clientId === clientIdB; |
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.
The problem is that we are just assuming that the caret is in block B when merging blocks, while it could be in either.
I guess more accurately: It could be either, or neither? Which to me sounds like a reasonable qualification to consider, since I should be able to call mergeBlocks
on any two blocks, selected or otherwise.
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.
Yes, that's why I added the hasSelection
check. If none of the blocks have selection, the caret replacement will be skipped.
updatedAttributes[ newAttributeKey ] = newHtml; | ||
|
||
dispatch( selectionChange( | ||
blockA.clientId, |
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.
Am I correct in thinking: While the selection may be within one or the other (or neither) of the two blocks, the merge will result in the first block becoming selected (if a selection had existed previously).
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.
Should it? I didn't think much about it. If there was no selection previously, there's no selection to be merged?
I added the label |
@gziolo Actually, we don't need this label here because this bug is not on WP 5.2 |
👋 , feel free to update or close #15619 if this PR fixes it, thanks! |
Description
Probably regressed in #14640. The problem is that we are just assuming that the caret is in block B when merging blocks, while it could be in either. I updated the code to look which block is selected.
How has this been tested?
Merge two paragraph blocks with the
Delete
key (orFn+Delete
for Mac). Caret should be at merge point.Screenshots
Types of changes
Checklist: