webcompat / web-bugs

A place to report bugs on websites.
https://webcompat.com
Mozilla Public License 2.0
742 stars 65 forks source link

www.sqlbi.com - "Copy" button fails to copy the code #128581

Open przemo20 opened 1 year ago

przemo20 commented 1 year ago

URL: https://www.sqlbi.com/blog/marco/2018/06/24/correct-calculate-of-age-in-dax-from-birthday/

Browser / Version: Firefox 118.0 Operating System: Windows 10 Tested Another Browser: Yes Chrome

Problem type: Something else Description: The Copy button works only one time on Firefox Steps to Reproduce: Example steps to reproduce:

  1. Go to https://www.sqlbi.com/blog/marco/2018/06/24/correct-calculate-of-age-in-dax-from-birthday/
  2. Click on the “Copy” button under the first DAX code (above the “If you do not have any blank, you can return the Age variable skipping the CheckedAge variable calculation” text).
  3. Paste the copied code to notepad; it should paste correctly (if not, try reloading the page and redo the last two steps)
  4. Now go back to the site, and click on the Copy button under some other piece of code, let's say, the code above “ORIGINAL BLOG POST” text.
  5. Paste the copied code to notepad – now the code we copied in step 2 should still be pasted, instead of the new one. For some reason, on Firefox, copying of the codes on that site is an „one-time action” and you need to reload page for copying to work again.
Browser Configuration
  • None

From webcompat.com with ❤️

softvision-raul-bucata commented 1 year ago

We appreciate your report. I was able to reproduce the issue by following the steps to reproduce. The code, even at the first attempt, does not get copied, as the previous entry remains (in my example, the URL from this report):

https://github.com/webcompat/web-bugs/assets/75027050/1be8ea5c-bd78-412b-bd03-81b61ce7fcae

Tested with:

Browser / Version: Firefox Release 118.0.2 (64-bit)/ Firefox Nightly 120.0a1 (2023-10-17) (64-bit) /Chrome Version 118.0.5993.71 (Official Build) (64-bit) /M Operating System: Windows 10 PRO x64

Notes:

  1. Reproducible regardless of the status of ETP.
  2. Reproducible on the latest build of Firefox Nightly and Release.
  3. Works as expected using Chrome.

Moving this to NeedsDiagnosis for further investigations.

[qa_42/2023]

wisniewskit commented 1 year ago

This code is run when you try to copy:

i.append(n), n.css("text-transform", "initial").attr("contenteditable", !0).html(a.html()).select().on("focus", (function() {
        document.execCommand("selectAll", !1, null)
      })).focus(), document.execCommand("copy"), n.remove(), i.html("<strong>Copied!</strong>"),

That approach to copying may simply not work on all browsers, because they have different criteria for allowing execCommand(copy). It's plausible this is the same as bug 1634273.