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

Code block copy button has no visible indicator on keyboard focus #12118

Open
glin opened this issue Feb 18, 2025 · 4 comments
Open

Code block copy button has no visible indicator on keyboard focus #12118

glin opened this issue Feb 18, 2025 · 4 comments
Assignees
Labels
accessibility bug Something isn't working html Issues with HTML and related web technology (html/css/scss) themes Related to HTML theming or any other style related issue (like highlight-style)
Milestone

Comments

@glin
Copy link

glin commented Feb 18, 2025

Bug description

Minor accessibility issue: when navigating to the Copy button within a code block using a keyboard, there's no visual indicator that the button has been focused.

In Quarto 1.6.39, the copy button doesn't appear at all. Here, I have keyboard focus on the copy button:

Code block with copy button focused

https://docs.posit.co/connect/2025.01.0/admin/r/#disabling-r-support


In the current Quarto docs, it seems that the Copy button is now always visible, which is a nice change. I'm not sure if that was a change in a later Quarto version or if this is a config option somewhere.

However, there is still no visible indicator that you have focus on the Copy button. Here I have keyboard focus on the first copy button, but it's visibly indistinguishable:

Code block with the first copy button focused

https://quarto.org/docs/output-formats/html-code.html#hiding-code

Steps to reproduce

  1. Navigate to any code block using your keyboard
  1. Press the Tab key until keyboard focus reaches the code block's Copy button.

Actual behavior

There is no visual indicator that the button is focused. The copy button will still be operable though - you can still use Enter/Space to click it.

Expected behavior

There should be a visual indicator that the copy button is focused. Ideally something that's not purely a change to color (which I've seen in doc sites before and has issues). I think the usual button focus outline is pretty common to see on doc sites. For example, on this MkDocs Material site: https://docs.posit.co/rspm/2024.11.0/admin/getting-started/installation/installing-ppm/#initial-configuration

Copy button focused on MkDocs Material site

Your environment

No response

Quarto check output

$ quarto check
Quarto 1.6.39
[✓] Checking environment information...
      Quarto cache location: /root/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.4.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.46.3: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.6.39
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Tex:  (not detected)

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.4
      Path: /opt/python/3.12.4/bin/python3
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

      There is an unactivated Python environment in .venv-uv. Did you forget to activate it?

[✓] Checking R installation...........OK
      Version: 4.3.3
      Path: /opt/R/4.3.3/lib/R
      LibPaths:
        - /opt/R/4.3.3/lib/R/library
      knitr: 1.49
      rmarkdown: 2.29

[✓] Checking Knitr engine render......OK
@glin glin added the bug Something isn't working label Feb 18, 2025
@mcanouil
Copy link
Collaborator

Quarto.org uses the pre-release 1.7.13.
The Quarto version used is stored in as meta in the header of the HTML page.

<meta name="generator" content="quarto-1.7.13">

@mcanouil mcanouil added the html Issues with HTML and related web technology (html/css/scss) label Feb 19, 2025
@mcanouil
Copy link
Collaborator

mcanouil commented Feb 19, 2025

Note that copy-button is documented at https://quarto.org/docs/output-formats/html-code.html#copy-button
The difference of behaviours you see is based on this setting not the Quarto version being used.

Note also, that you can use the "edit this page" on Quarto.org to see the source code of the page which shows that the page does not use the default but code-copy: true instead.

@cderv cderv added html Issues with HTML and related web technology (html/css/scss) themes Related to HTML theming or any other style related issue (like highlight-style) and removed html Issues with HTML and related web technology (html/css/scss) labels Feb 19, 2025
@cderv
Copy link
Collaborator

cderv commented Feb 19, 2025

Thanks for the feedback @glin !

We need to tweak copy button insertion to get the right browser inserted outline on focus-visible.

Bootstrap has a specific helper https://getbootstrap.com/docs/5.3/helpers/focus-ring/ but not sure we need this; I'll have a look

I noticed we have explicit removal in our SCSS currently

.code-copy-button:focus {
outline: none;
}

This is preventing the :focus-visible to apply even when code-copy: true

So I need to see what could be done to adapt.

@cderv cderv self-assigned this Feb 19, 2025
@cderv cderv added this to the v1.7 milestone Feb 19, 2025
@glin
Copy link
Author

glin commented Feb 19, 2025

@mcanouil Thanks for the pointers! I'm brand new to Quarto so these are very helpful. and also good to know about that config option.

@cderv I see, so when I manually remove that styling rule, the copy button focus works exactly as I'd expect. Keyboard focus turns on the focus outline, and mouse focus still keeps the focus outline hidden. Looks like there's already another rule that turns off outlines for mouse-only :focus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility bug Something isn't working html Issues with HTML and related web technology (html/css/scss) themes Related to HTML theming or any other style related issue (like highlight-style)
Projects
None yet
Development

No branches or pull requests

3 participants