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

[Bug:Docs] Copy button broken in Firefox #818

Open
4 of 6 tasks
danawoodman opened this issue Feb 28, 2024 · 3 comments
Open
4 of 6 tasks

[Bug:Docs] Copy button broken in Firefox #818

danawoodman opened this issue Feb 28, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@danawoodman
Copy link

danawoodman commented Feb 28, 2024

What were you trying to install (or what else went wrong)?

trying to copy the install code for a library

What exactly did you do?

hit the copy button on the zig install on this page: https://webinstall.dev/zig/

What went wrong?

nothing happened, copy failed, console produced this error:
Screenshot 2024-02-28 at 11 17 20 AM

Which OS did you try on?

macOS 14.3.1, Firefox 123.0

  • Mac
  • Windows
  • Linux

What type of computer (i.e. laptop, desktop, Raspberry Pi)?

  • Laptop or Desktop (amd64 / x86-64)
  • Raspberry Pi (ARM-64)
  • Other (please specify, if you know)
@danawoodman danawoodman added the bug Something isn't working label Feb 28, 2024
@HacDan
Copy link
Collaborator

HacDan commented Feb 29, 2024

Can confirm happens on Firefox in PopOS (Ubuntu Derivative) as well.

Also noticed (although should probably be a separate issue) that OS detection isn't functioning in Firefox on PopOS. Seems this isn't the case. My useragent is being incorrectly displayed.

I'll test Firefox on MacOS tonight. Can confirm I receive the same error with Firefox on MacOS(Honestly this was expected. It's an error in the handling of javascript)

@y0rune
Copy link
Collaborator

y0rune commented Mar 10, 2024

I confirm that error on Firefox at Mac (123.01), Windows 11, Linux :c

@coolaj86
Copy link
Member

coolaj86 commented Sep 9, 2024

I just did this for something else. I believe this function should work in Firefox:

function copyUrlToClipboard(text) {
  if (navigator.clipboard && window.isSecureContext) {
    navigator.clipboard.writeText(text).then(() => {
      console.log('URL copied to clipboard.');
    }).catch((err) => {
      console.error('Failed to copy the URL: ', err);
    });
    return;
  }

    const textArea = document.createElement('textarea');
    textArea.value = text;
    textArea.style.position = 'fixed'; // avoid scrolling to bottom
    textArea.style.opacity = '0'; // hidden
    document.body.appendChild(textArea);
    textArea.focus();
    textArea.select();
    
    try {
      document.execCommand('copy');
      console.log('URL copied to clipboard.');
    } catch (err) {
      console.error('Failed to copy the URL: ', err);
    }
    
    document.body.removeChild(textArea);
}

copyUrlToClipboard(text);

It's used here: https://x5c.bnna.net/

Update:
I just downloaded Firefox (and had to fix a different bug on that site), but confirmed that the copyToClipboard works.
Truth be told, however, I didn't create the website and I often have trouble making edits to it because... modern frameworks 🤦‍♂️🔫.
I've gotta see if there's a simple way to edit the page I need to edit, or if there's a simple way to sidestep the framework - ajQuery is more my speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants