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

Added alt param #3006

Merged
merged 10 commits into from Aug 31, 2020
Merged

Added alt param #3006

merged 10 commits into from Aug 31, 2020

Conversation

jooyoungseo
Copy link

@jooyoungseo jooyoungseo commented Aug 18, 2020

This ready-for-review PR attempts to follow up with the PR #2494 to address the alt text issue #612.

We have to make sure alt attribute to be dynamic (beyond static).

Adding alt param to render*() instead of *Output() makes more sense to me (the actual screen reader user) given that we may want to have dynamic alt text depending on graph changes.

Reprex

  • Confirmed the following dynamic alt text works very well for screen readers
library(shiny)

shinyApp(
  ui = fluidPage(
    actionButton("btn1", "Update plots"),
    plotOutput("plot1", width = "400px")
  ),
  server = function(input, output, session) {
    dt <- reactive({
      invalidateLater(3 * 1000)
      rnorm(30)
    })
    output$plot1 <- renderPlot(
      {
        hist(dt())
      },
      alt = reactive({
        paste("Dynamic alt text. Mean(x):", round(mean(dt()), 3))
      })
    )
  }
)

R/render-cached-plot.R Outdated Show resolved Hide resolved
R/render-cached-plot.R Show resolved Hide resolved
R/render-cached-plot.R Show resolved Hide resolved
R/render-cached-plot.R Outdated Show resolved Hide resolved
R/render-cached-plot.R Show resolved Hide resolved
R/render-plot.R Outdated Show resolved Hide resolved
R/render-plot.R Show resolved Hide resolved
R/render-plot.R Show resolved Hide resolved
R/render-plot.R Show resolved Hide resolved
R/render-plot.R Show resolved Hide resolved
R/render-plot.R Outdated Show resolved Hide resolved
R/render-plot.R Outdated Show resolved Hide resolved
R/render-cached-plot.R Outdated Show resolved Hide resolved
Copy link
Collaborator

@schloerke schloerke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's allow for alt to be reactive. (Sorry for my misleading comments earlier!)

@schloerke
Copy link
Collaborator

reprex goal:

shinyApp(
  ui = fluidPage(
    actionButton("btn1", "Update plots"),
    plotOutput("plot1", width = "400px")
  ),
  server = function(input, output, session) {
    dt <- reactive({
      invalidateLater(3 * 1000)
      rnorm(30)
    })
    output$plot1 <- renderPlot(
      {
        hist(dt())
      },
      alt = reactive({
        paste("Dynamic alt text. Mean(x):", round(mean(dt()), 3))
      })
    )
  }
)

JooYoung Seo and others added 4 commits August 18, 2020 14:23
Co-authored-by: Barret Schloerke <barret@rstudio.com>
Co-authored-by: Barret Schloerke <barret@rstudio.com>
Co-authored-by: Barret Schloerke <barret@rstudio.com>
@jooyoungseo
Copy link
Author

@schloerke, we've made it!

I have confirmed the reactive expr is dynamically passed to alt param. When not provided, defaulting to "plot object" announced to screen readers :)

R/render-cached-plot.R Outdated Show resolved Hide resolved
R/render-plot.R Outdated Show resolved Hide resolved
@jooyoungseo jooyoungseo marked this pull request as ready for review August 18, 2020 21:29
@jooyoungseo jooyoungseo linked an issue Aug 18, 2020 that may be closed by this pull request
@cpsievert cpsievert self-requested a review August 18, 2020 21:47
Copy link
Collaborator

@cpsievert cpsievert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after default alt value is addressed

@jooyoungseo jooyoungseo requested a review from wch August 18, 2020 23:05
@cpsievert cpsievert added this to the 1.5.1 milestone Aug 19, 2020
R/render-cached-plot.R Outdated Show resolved Hide resolved
Co-authored-by: Barret Schloerke <barret@rstudio.com>
Copy link
Collaborator

@schloerke schloerke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending alt retrieval in renderCachedPlot.

R/render-cached-plot.R Show resolved Hide resolved
@wch wch merged commit 20bc4e7 into rstudio:master Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

request: pass ALT text to renderPlot
4 participants