Skip to content

Fix copy-to-clipboard within Tabs

Sarah German requested to merge 1696-clippy-tabs into main

What does this MR do and why?

The copy-to-clipboard utility does not work when content is loaded within Tabs: https://docs.gitlab.com/ee/administration/operations/rails_console.html#starting-a-rails-console-session

This MR fixes this problem by wrapping the clipboard script in window.onload = () => {}, which ensures that it runs after Tabs have initialized.

This MR also refactors out a bit more jQuery code, although the Clipboard script does still require it due to the Bootstrap 4.x tooltips.

Closes #1696 (closed)

How to validate

You can test this in the review app: https://1696-clippy-tabs.docs.gitlab-review.app

  1. Visit a page that has a code block within tabs, like this one: https://1696-clippy-tabs.docs.gitlab-review.app/ee/administration/operations/gitlab_sshd.html?tab=Linux+package+%28Omnibus%29#enable-gitlab-sshd
  2. Verify you can use the "copy" button in the top-right of the code block to copy the contents of the code block.

Merge request 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 Sarah German

Merge request reports