Skip to content

Patch to fix functionality with copy button of embedded snippet

Michael Le requested to merge mle/patch-87677-copy-snippet into master

What does this MR do and why?

  • Change copy functionality from using navigator.clipboard API to document.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.

image

Screenshots or screen recordings

No change from !87677 (merged)

Hover state

CleanShot_2022-06-07_at_12.38.13

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.

Edited by Michael Le

Merge request reports