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

Firefox: Triple click + Ctrl+c in code block copies two lines instead of one #10495

Open
4 of 7 tasks
matevz opened this issue Sep 12, 2024 · 4 comments
Open
4 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@matevz
Copy link

matevz commented Sep 12, 2024

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

On Mozilla Firefox when selecting a line in the code block using a triple click, it selects it fine. But if you copy it, it copies both the line you selected and one line above. This is really annoying when copy&pasting specific lines for example in bash scripts or config files. Using triple click in normal text paragraphs works fine.

Reproducible demo

No response

Steps to reproduce

  1. Open a docusaurus website containing code blocks with multiple lines, e.g. https://docs.oasis.io/rofl/app#app-definition or simply https://docusaurus.io/docs/next/cli
  2. Select a line of code using triple-click
  3. Copy it
  4. Paste it somewhere

Expected behavior

The copied line is pasted.

Actual behavior

Two lines are pasted: The copied line and one before.

Your environment

Self-service

  • I'd be willing to fix this bug myself.
@matevz matevz added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Sep 12, 2024
@slorber
Copy link
Collaborator

slorber commented Sep 12, 2024

Thanks for reporting

Indeed this is really surprising. I can only reproduce it in Firefox.

And I can't reproduce it using prism-react-renderer demo https://stackblitz.com/~/github.com/FormidableLabs/prism-react-renderer
(Run pnpm build && pnpm start:demo)

It looks like a Firefox bug that only affects Docusaurus sites 🤷‍♂️
Even though it's probably not our fault, we could investigate to find a workaround.

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Sep 12, 2024
@lukaw3d
Copy link

lukaw3d commented Sep 12, 2024

Quickly scanning the code I would guess the cause is span here, instead of div

@xyheng123 xyheng123 mentioned this issue Oct 26, 2024
3 tasks
@matevz
Copy link
Author

matevz commented Nov 14, 2024

I can confirm the issue still exists on Firefox 131.0.3 and Docusaurus 3.6.1.

Was #10621 spam?

@slorber
Copy link
Collaborator

slorber commented Nov 14, 2024

The code of that PR is not even working, probably AI-generated

CleanShot 2024-11-14 at 12 05 56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

3 participants