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

Text inside pseudo-elements is selectable but does not copy #3492

Open
1 task
Psychpsyo opened this issue Feb 7, 2025 · 0 comments
Open
1 task

Text inside pseudo-elements is selectable but does not copy #3492

Psychpsyo opened this issue Feb 7, 2025 · 0 comments

Comments

@Psychpsyo
Copy link
Contributor

Psychpsyo commented Feb 7, 2025

Summary

When I select text in a ::before or ::after pseudo-element and then copy my selection with Ctrl+C, the text is not included in the clipboard.
This is very unintuitive.

Note:
Selecting the text in these pseudos is generally quite tricky, but Ctrl+A does it reliably for any pseudos that aren't on the root element.
With more complicated layouts, I can also get it to happen by starting drags inside the padding areas of elements with pseudos.

The spec for user-select says that the UA may apply it to pseudo elements.
In such a case, they are user-select: none by default, but can be changed to other values.
Since we currently only support a single range per selection, we are allowed (but not forced) to select them, even in the user-select: none case if our single range starts before and ends after the pseudo element.

Overall: The visible selection should match what gets copied to the clipboard, one way or another.

Operating system

Linux

Steps to reproduce

  1. Open the reduced test case.
  2. Use Ctrl+A to select all the text.
  3. The word 'hello' is now selected.
  4. Press Ctrl+C to copy all the text.
  5. Paste it somewhere and notice the missing word.

Expected behavior

The word 'hello' should be included in the copy.

Actual behavior

The word 'hello' is not included in the copy.

URL for a reduced test case

N/A

HTML/SVG/etc. source for a reduced test case

<!DOCTYPE html>
<style>
  span::before {
    content: "hello";
  }
</style>
Well <span> friends!</span>

Log output and (if possible) backtrace

None

Screenshots or screen recordings

Image

Build flags or config settings

None

Contribute a patch?

  • I’ll contribute a patch for this myself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant