Skip to content

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

Closed

Description

@matevz

Have you read the Contributing Guidelines on issues?

Prerequisites

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://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.

Activity

  1. added
    bug
    status: needs triage
    on Sep 12, 2024
  2. slorber commented on Sep 12, 2024

    @slorber
    Collaborator

    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.

  3. removed
    status: needs triage
    on Sep 12, 2024
  4. lukaw3d commented on Sep 12, 2024

    @lukaw3d
  5. matevz commented on Nov 14, 2024

    @matevz
    Author

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

    Was #10621 spam?

  6. slorber commented on Nov 14, 2024

    @slorber
    Collaborator

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

    CleanShot 2024-11-14 at 12 05 56

  7. mwestphal commented on Nov 15, 2025

    @mwestphal
  8. slorber commented on Nov 21, 2025

    @slorber
    Collaborator

    A span (or display: inline) should work; I've seen plenty of code blocks in other documentation systems that do not lead to this weird Firefox-only problem, and couldn't really figure out why it only seems to affect us.

    But since using a <div> doesn't seem to produce any weird side-effect, let's make the change: #11565

    This is also what the underlying lib recommends apparently: https://github.com/FormidableLabs/prism-react-renderer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions