-
Notifications
You must be signed in to change notification settings - Fork 367
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
Reinstate clipboard functionality #339
base: main
Are you sure you want to change the base?
Conversation
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.
Thank you for contributing, @wesbos!
I've left some minor suggestions.
It would be also nice to see unit test for ClipboardCopy and playwright test for the whole feature.
if (typeof children === 'undefined' || children === null) { | ||
return | ||
} | ||
navigator.clipboard.writeText(children.toString()) |
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'd consider waiting for permission returned from writeText
resolves or rejects, and handle potential rejection.
style={{ | ||
cursor: 'pointer', | ||
scale: copied ? `1.15` : `1`, | ||
transition: 'scale 0.2s ease-in-out' |
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'd suggest defining styles in scss file, to keep it consistent with other components
@@ -6,6 +6,6 @@ export const getKeyCodeEvent = ( | |||
): KeyCodeEvent | undefined => { | |||
return keyCodeEventValues.find( | |||
keyCodeEvent => | |||
keyCodeEvent.code === keyCode.code && keyCodeEvent.key === keyCode.key | |||
keyCodeEvent.code === keyCode.code || keyCodeEvent.key === keyCode.key |
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.
Would you consider removing that change here, and keep it in #338? That would make tracking it easier
setCopied(true) | ||
setTimeout(() => { | ||
setCopied(false) | ||
}, 200) |
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 think it would be nice to clear it on component unmount, WDYT?
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 for an animation, so it needs to zoom out after quickly. Otherwise they would just stay scaled up until the component unmounts
Thanks - I really don’t have a ton of time for this, just hoping to restate the functionality the site had before I sold it. If it needs multiple components and tests just to write a string to clipboard, I guess we will just need to do without |
Fixes #336