Patch to fix functionality with copy button of embedded snippet
What does this MR do and why?
- Change copy functionality from using
navigator.clipboard
API todocument.execCommand('copy')
to handle permission checks - Add hover state for button
Why
In !87677 (merged), we were using the Clipboard API to copy text on the page. This worked with localhost during testing but when used in a third party website this API requires permission to work. This would mean any site that had a GitLab embed on it would prompt for a permission request. To make this experience discrete, opting to use document.execCommand('copy')
instead. This approach is the same one we are using when we are using ClipboardJS in the rest of the application.
Screenshots or screen recordings
No change from !87677 (merged)
Hover state
How to set up and validate locally
See !87677 (merged)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Michael Le