Skip to content
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

Web UI copy-to-clipboard not working #483

Closed
cpaelzer opened this issue May 7, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@cpaelzer
Copy link

commented May 7, 2019

Note: This is not a UA-client issue, but I file it here for you to re-route it accordingly.

That failing button is defined as:

<div class="p-code-snippet">
  <input type="text"
         id="ua-token"
         class="p-code-snippet__input"
         value="..."
         readonly="readonly">
  <button class="p-code-snippet__action">Copy to clipboard</button>
</div>

Affected Browsers (What is in Bionic as of today):

  • Chrome 74.0.3729.108-1
  • Firefox 66.0.3+build1-0ubuntu0.18.04.1

The css is from the vanilla framework, inspection shows vanilla-framework-version-1.8.1.css

Based on that I guessed that some JS in the vanilla framework would assign an onclick to this class, but I haven't found any JS other than the google analytics. Of course my 20 year old web-foo might just be outdated.

Screenshot_noJS-forCopyButton

But knowing that we use that style all over out tutorials and such I tried there and it worked fine e.g. on provisioning maas

Inspecting (and comparing) that showed the same button tech:
<button class="p-code-snippet__action">Copy to clipboard</button>

But the broken (contracts.canonical.com) had no Event Listeners at all on that button.
While the tutorial had several registered, those were a bunch of google analytics tags but more importantly also this:

Screenshot_noJS-forCopyButton-codeOnOtherPage

This seems to be the missing code

    n.commandLine = function() {
        document.querySelectorAll(".p-code-snippet").forEach(function(a) {
            var e = a.querySelector(".p-code-snippet__action")
              , n = a.querySelector(".p-code-snippet__input");
            e && n && e.addEventListener("click", function(e) {
                n.select(),
                e.preventDefault;
                try {
                    document.execCommand("copy");

And knowing that we find in the main page the loaders:

</footer>
        <!-- Polyfill functions -->
[...]
    <script src="/static/js/build/main.min.js?v=a3555ea"></script>
    <script src="https://assets.ubuntu.com/v1/f5bf3854-respond.min.js"></script>

And the broken page has nothing there:

        </div>
      </footer>
    </div>
  </body>
</html>

Please fix https://auth.contracts.canonical.com/ to carry the code to be active on that copy-to-clipboard button

@OddBloke OddBloke changed the title Web UI coyp-to-clipboard not working Web UI copy-to-clipboard not working May 7, 2019

@blackboxsw

This comment has been minimized.

Copy link
Contributor

commented May 8, 2019

As mentioned, this is an issue with the UA frontend not ua-client or ua-contracts specifically. Forwarding this issue to the appropriate project https://github.com/canonical-web-and-design/ua-token

@blackboxsw

This comment has been minimized.

Copy link
Contributor

commented May 8, 2019

@blackboxsw blackboxsw closed this May 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.