-
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
Compose: Add new useCopyToClipboard
hook
#29643
Conversation
<ClipboardButton | ||
text={ () => serialize( blocks ) } | ||
role="menuitem" | ||
className="components-menu-item__button" |
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.
Notice how we can use the MenuItem
here instead of emulating it.
Size Change: +207 B (0%) Total Size: 1.4 MB
ℹ️ View Unchanged
|
|
||
return ( | ||
<ToolbarButton | ||
className="components-clipboard-toolbar-button" | ||
ref={ ref } | ||
disabled={ disabled } | ||
> | ||
{ hasCopied ? __( 'Copied!' ) : __( 'Copy URL' ) } |
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 changes the behavior from the button label change to snacker, I just want to make sure that this is what we want :)
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.
Seems good on the API side but in several places we move from updating the button state towards snackbars to indicate that the copy happened, I just want to make sure designers are on board with this.
If that's not what we want, I can change it back, but I thought that's what we want since we started doing it in other places. |
👋 Thanks for the ping! I understand this is the question of the day?
I always thought the button label change was a bit too unique. I'm personally leaning towards a snackbar being a better pattern for this. |
I agree the notification is better, and hopefully that integrates better with a11y announcements too. |
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 looking good
Great, thanks! |
useCopyToClipboard
hook
Why do we need to deprecate the |
The problem with |
Description
The hook I created in #22224 is flawed because it would stop working if the ref is updated.
There's no way to fix the hook without changing the API, so I created a new hook and deprecated the flawed hook.
A lot of copy buttons have shifted from changing the button text on copy to a notice, so I removed the
hasCopied
state from the hook, which would also be problematic to return if we have to return a ref.I also deprecated
ClipboardButton
.How has this been tested?
Screenshots
Types of changes
Checklist: