-
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
List: copy wrapper when multi selecting items #59460
Conversation
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. |
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! I did a quick test and it appears to be working as expected.
I think we should also remove the useCopy
hook export:
export { default as useCopy } from './use-copy'; |
@@ -27,6 +29,7 @@ export const settings = { | |||
}; | |||
}, | |||
transforms, | |||
[ unlock( privateApis ).requiresWrapperOnCopy ]: true, |
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.
Does this implicitly expose the block's new configuration? Or do we need to add new support like __unstableRequiresWrapperOnCopy
to block.json, similar to __unstablePasteTextInline
etc?
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.
For example, when I copied and pasted Button, Column, etc. that depend on the parent block, I found that the block could not be pasted like this problem. I imagine that similar problems can be solved by adding it as block support.
8e662ccb71cffea62cfb1017b2560d0b.mp4
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.
Does this implicitly expose the block's new configuration?
What do you mean? How is it exposed? You need the key to be able to retrieve it.
Sure, we could add it to column and button in the same way. I still prefer using a symbol until we properly stabilise it.
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.
For example, developers may discover and use this new key when creating custom blocks. Since it is a private API, is it okay not to take that into account?
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.
Since it is a private API, is it okay not to take that into account?
Sorry, I'm not sure what you mean by not taking it into account? Since it's a private symbol, you can't access or set it unless you have know to the symbol (unlike strings).
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 see, then there's no problem. Maybe I didn't understand what a Symbol was 😅
Size Change: +117 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
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.
LGTM! It also works with nested list items and correctly inherits the parent's attributes.
b7d9510ffde0f03efb00601cb4c4c19d.mp4
Thanks @t-hamano! |
Co-authored-by: ellatrix <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: annezazu <[email protected]>
I just cherry-picked this PR to the update/packages-6.5-rc1 branch to get it included in the next release: 13e2c3f |
Co-authored-by: ellatrix <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: annezazu <[email protected]>
What?
Fixes #59381. The problem is that the logic setting the wrapper does not execute when there a multi selection of list items, because it's based on a ref and event listeners.
Why?
Fixes #59381.
How?
Add a block type setting and check inside
setClipboardBlocks
instead, which will work for both single and multi selection.Testing Instructions
Added a test that fails in trunk. press cmd+a twice in a list to select all list items, then paste into an empty paragraph.
Testing Instructions for Keyboard
Screenshots or screencast