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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying code block content doesn't preserve newlines on Firefox #5663

Closed
5 tasks done
Martinsos opened this issue Oct 8, 2021 · 6 comments 路 Fixed by #5668
Closed
5 tasks done

Copying code block content doesn't preserve newlines on Firefox #5663

Martinsos opened this issue Oct 8, 2021 · 6 comments 路 Fixed by #5668
Labels
bug An error in the Docusaurus core causing instability or issues with its execution help wanted Asking for outside help and/or contributions to this particular issue or PR.

Comments

@Martinsos
Copy link
Contributor

Martinsos commented Oct 8, 2021

馃悰 Bug Report

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

Open https://docusaurus.io/docs/markdown-features/code-blocks in Firefox, select piece of code from code block, press Ctrl+C to copy it, paste it anywhere (e.g. in text editor), and notice how newlines are lost.

On Chrome this problem doesn't exist and newlines are correctly preserved/captured.

If "copy" button (in the top-right corner) is used, newlines are preserved though, even on Firefox. But "copy" button requires copying the whole block of code, you can't copy just part of it.

I tried doing the same thing at https://mdxjs.com/, and there copying works ok, newlines are preserved on Firefox.

Have you read the Contributing Guidelines on issues?

Yes

Your environment

ArchLinux 5.14.7-arch1-1, Firefox 93.0 (64-bit).

@Martinsos Martinsos 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 Oct 8, 2021
@slorber
Copy link
Collaborator

slorber commented Oct 8, 2021

Couldn't reproduce on Firefox 0.92 MacOS

@slorber slorber added help wanted Asking for outside help and/or contributions to this particular issue or PR. and removed status: needs triage This issue has not been triaged by maintainers labels Oct 8, 2021
@matijaSos
Copy link
Contributor

matijaSos commented Oct 8, 2021

I have the same problem as @Martinsos on Firefox 93.0 MacOS Catalina 10.15.7

@Martinsos
Copy link
Contributor Author

I was just able to reproduce the same problem on Windows 10, Firefox 93.0.

Here is GIF:

docusaurus-bug

For some reason the pasting page didn't have "paste"but I used CTRL+V. Same behaviour is if I use right-click + paste in other editors.

@slorber
Copy link
Collaborator

slorber commented Oct 8, 2021

oh I can reproduce indeed, it's the selection that can't copy lines, not the copy button that works everywhere.

@Martinsos
Copy link
Contributor Author

oh I can reproduce indeed, it's the selection that can't copy lines, not the copy button that works everywhere.

Exactly! The problem is, sometimes a block of code might be relatively big and somebody might need to copy just a part of it. We had this situation in our tutorial, where we guide people to copy the highlighted piece of the code, and then user reported this issue on firefox.

@lex111
Copy link
Contributor

lex111 commented Oct 8, 2021

Oh, this is quite serious bug, it should be fixed in this PR #5668.

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 help wanted Asking for outside help and/or contributions to this particular issue or PR.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants