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

Copy button not shown on some pages #205

Open
nijel opened this issue Apr 12, 2023 · 3 comments
Open

Copy button not shown on some pages #205

nijel opened this issue Apr 12, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@nijel
Copy link

nijel commented Apr 12, 2023

Describe the bug

context
When I go to https://docs.weblate.org/en/latest/api.html, the copy button is not present, while it works fine on other pages.

expectation
I expected copy button to occur.

bug
But instead nothing happens. There are no error messages in the browser. The code is within div.highlight pre selector, so the copy button should be present.

problem

Looking at the code, it seems that window.ClipboardJS is not initialized for some reason and that blocks adding copy buttons:

if (window.ClipboardJS === undefined) {

I have no clue why it fails to load, but maybe it's time to drop this code and use
navigator.clipboard.writeText directly as described in #97?

Reproduce the bug

I currently have no clue how to reproduce this outside our documentation. The source code is here: https://github.com/WeblateOrg/weblate/tree/main/docs

List your environment

furo==2023.03.27
pygments==2.15.0
Sphinx==6.1.3
sphinx-copybutton==0.5.1
sphinx-jsonschema==1.19.1
sphinxcontrib-httpdomain==1.8.1
sphinxext-opengraph==0.8.1
@nijel nijel added the bug Something isn't working label Apr 12, 2023
@welcome
Copy link

welcome bot commented Apr 12, 2023

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@stefanodavid
Copy link
Contributor

@nijel out of curiosity (and thanks to 15 minutes free!) I made a build of Weblate's docs and, to my surprise, if you change the theme from furo to sphinx_rtd_theme, the copybuttons are shown. So in the end it might not be a bug in this extension, but some strange interaction with furo?

@nijel
Copy link
Author

nijel commented Apr 14, 2023

You're right, it works with some other theme. It also works with the Furo theme if I move the inclusion of the clipboard.min.js script somewhere in the middle of the document. I have no clue why it silently fails to initialize when it is at the bottom.

Instead of debugging obsolete code of clipboard.js, I decided to avoid it in #206

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

Successfully merging a pull request may close this issue.

2 participants