Skip to content

Selection of text from codeblock in Chrome is glitchy #874

@aseagram

Description

@aseagram

Trying to select text within a codeblock in Chrome (80.0.3987.163, Windows 10) results in some glitchy behaviour. Here is an example from your example GitBook page, below. It is nearly impossible to select single words, single lines or groups of lines, etc.

Native text selection appears to be prevented here because each line of source code has the CSS pointer-events: none set on it. I believe that this property was set in an effort to prevent the underline from appearing when you hover each line of code, since they are marked up as <a> tags. I see two options:

  1. Convert the <a> tags to <span> tags and remove the pointer-events: none declaration.
  2. Remove the pointer-events: none declaration and instead prevent the underline from appearing on hover by specifying a.sourceLine, a.sourceLine:hover { text-decoration: none; }.

bookdown_select


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('bookdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/bookdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions