-
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
Prevent unexpected copying of the post title #41284
Conversation
Size Change: +9.98 kB (+1%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
The unit test failed, so I would like to find out where the mistake is. |
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.
Thanks for the PR, @t-hamano.
I didn't get a chance to start reviewing this yet.
Can you update the title and description so it matches the latest changes?
@Mamaduka |
c4a7de0
to
ea31055
Compare
The rebasing passed all tests. |
I have confirmed that this problem still reproduces with the latest trunk. I have also confirmed that this PR will solve the problem. |
Taking a look at this now! |
Thanks for the PR @t-hamano! I've tested it and confirmed that it fixes both issues as you described.
|
I don't think we should fix this by adding an exception to Is there an alternative way to fix this in Thinking more higher level, I think this is yet another example of why it was a mistake to implement widget areas using blocks 😅 See #33254. |
Thank you for the review, @michalczaplinski!
This PR prohibits the copying of the widget area itself, so the snack bar message itself does not appear to indicate that it has been copied. |
Hey @t-hamano ! Aside from the question of the user experience I'm afraid I'll have to side with @noisysocks here (thanks for chiming in Robert, btw!). Sorry about this! I didn't consider that the I'd still very much like to fix this issue but I'm not very familiar with the |
I am trying to solve this in the |
As for the widget area fix, I have yet to find a workable solution, so I have cut it out as a separate issue #45398, and reverted the changes. Also, perhaps I should not have addressed the two issues at the same time. Sorry for the confusion 🙏 |
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 fix works great @t-hamano 👍
We can tackle the widgets issue in the other PR!
@edit: This PR originally attempted to solve the copying problem in the post title and the widget areas at the same time. However, I have decided to resolve the widget issues separately in a new issue #45398. For details, please see the edit history.
What?
This PR prevents copying of a post titles.
Why?
When text is selected in the post title,
getSelectedBlockClientIds
is executed.The post title is a block, but the
clientId
is empty, so the correct block name cannot be obtained at this point:https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/copy-handler/index.js#L34
As a result, a message with an undefined value is displayed.
post-title.mp4
How?
Make
getSelectedBlockClientIds
return an empty array if clientId of the selected block is an empty string or undefined value.Testing Instructions
Ctrl(Cmd)
+C
orCtrl(Cmd)
+X
.