quarto-ext / fontawesome

Use Font Awesome icons in HTML and PDF documents.
https://quarto-ext.github.io/fontawesome/
MIT License
109 stars 10 forks source link

Accessible icons #8

Closed mine-cetinkaya-rundel closed 2 years ago

mine-cetinkaya-rundel commented 2 years ago

There are some recommendations at https://fontawesome.com/docs/web/dig-deeper/accessibility for accessibility of Font Awesome icons. Generally, they include adding aria-hidden="true" and adding a title for icons with semantic or iterative meaning. It would be good to incorporate these in the extension.

mcanouil commented 2 years ago

This can easily (except for the title attribute) be done by simply adding the code in https://github.com/quarto-ext/fontawesome/blob/bb9eaa844dbcc847a1e186f9b08b6a64ad2d0d44/_extensions/fontawesome/fontawesome.lua#L26

mcanouil commented 2 years ago

I added this feature in #10

image
mcanouil commented 2 years ago

Should the aria-label be used instead of relying on "Auto-Accessibility with Kits" from FA? 🤔 I will try a screen reader to check if the current implementation (#10) does what it is supposed to.

cscheid commented 2 years ago

I will defer to @jooyoungseo's expertise on this. JooYoung, what is the right way for us to address accessibility concerns in these icon packages?

mcanouil commented 2 years ago
jooyoungseo commented 2 years ago

I see some issues with fontawesome implementation in {shiny} and {fontawesome} packages. I will further investigate this issue. Using title attribute is often debatable like this post. Also, some screen readers do not recognize title attribute unless users explicitly turn on related settings.

jooyoungseo commented 2 years ago

I think fontawesome's a11y recoomendation is debatable. they recommend using aria-hidden for the icons and provide alt text on a parent-level via aria-label. However, in many cases, fontawesome icons are used not just for decorative purpose, but also for informative communication. I think providing aria-label within <i> tag is more robust solution, and I would assign aria-label == fontname. I won't recommend aria-hidden.

jooyoungseo commented 2 years ago

In the following example (retrieved from example(checkboxGroupInput, package = "shiny")), icons are used for informative purpose. However, the checkbox is not accessible for screen readers until explicit aria-label is used by content creator because this does not provide any icon alt text by default. It would be more desirable and safer if the aria-label is provided by default equal to font name and allow content creators to override that value if necessary.

library(shiny)

ui <- fluidPage(
  checkboxGroupInput("icons", "Choose icons:",
    choiceNames =
      list(icon("calendar"), icon("bed"),
           icon("cog"), icon("bug")),
    choiceValues =
      list("calendar", "bed", "cog", "bug")
  ),
  textOutput("txt")
)

server <- function(input, output, session) {
  output$txt <- renderText({
    icons <- paste(input$icons, collapse = ", ")
    paste("You chose", icons)
  })
}

shinyApp(ui, server)
mcanouil commented 2 years ago

@jooyoungseo Thanks for these comments.

To note, screen readers are not the target tools for title, it's mostly for mouse pointers readers. Meaning, currently (with #10 merged) semantic icons are invisible to screen readers as is.

If I summarise you suggest to:

Did I miss anything?

@cscheid I can work on a PR if that's ok with you?

mcanouil commented 2 years ago

Hum, in my first tests (Draft PR #12), MacOS screen reader seems to be unable to read the aria-label from the example below:

Screenshot showing on the left a rendered document including inline icon as "A text with a {{< fa folder >}} icon in it." and on the right html code from developer mode "<p>A text with a "<i class=\"fa-solid fa-folder\" aria-label=\"folder\"></i> icon in it.</p>"
jooyoungseo commented 2 years ago

@mcanouil -- Would you mind providing me with the example code in plain text? It's currently displayed in image.

mcanouil commented 2 years ago

The following quarto/markdown:

A text with a {{< fa folder >}} icon in it.

produces the following HTML where MacOS screen reader omit the icon when reading:

<p>A text with a <i class="fa-solid fa-folder" aria-label="folder"></i> icon in it.</p>

This is the results of wip #12

cscheid commented 2 years ago

I think we have this now, so I'm going to close it.

dfolio commented 1 year ago

I think accessibility is great. But, when I'm running Chrome Lighthouse Audits on a page using this fontawesome extension (for instance with {{< fa file-pdf >}}), it complains about aria roles and attributes and I get:

Accessibility: [aria-*] attributes do not match their roles

Each ARIA role supports a specific subset of aria-* attributes. Mismatching these invalidates the aria-* attributes.

Failing Elements: i.fa-solid.fa-file-pdf

with the following html code

<i class="fa-solid fa-file-pdf" aria-label="file-pdf"></i>
mcanouil commented 1 year ago

I am not sure what it means exactly ... 🤔

Note that the aria-label here is the default that takes the icon label.

jooyoungseo commented 1 year ago

FYI, automatic accessibility audit tools are only able to capture ~80% violation, and sometimes gives us an aggressive result. I don't think we have used any aria role particularly for fontawesome and the warning above can be disregarded. I used role="presentation" for icons when I worked with shiny team, but that's deprecated. I will take a close look at the fontawesome a11y this summer.