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

verbatim popup with shiny validation or red error for disabled #102

Closed
Tracked by #69
nikolas-burkoff opened this issue Nov 4, 2022 · 4 comments · Fixed by #127
Closed
Tracked by #69

verbatim popup with shiny validation or red error for disabled #102

nikolas-burkoff opened this issue Nov 4, 2022 · 4 comments · Fixed by #127
Assignees
Labels

Comments

@nikolas-burkoff
Copy link
Contributor

nikolas-burkoff commented Nov 4, 2022

This used to come about on the mmrm module until it was fixed

image

Simpler reprex:

image

library(teal.code)
library(teal.widgets)
library(shiny)

ui <- fluidPage(
  verbatim_popup_ui("pop", "Warnings")
)

server <- function(input, output, session) {


  disabled <- reactive({
    validate(need(FALSE, "This is a validation but it is being shown!"))
    FALSE
  })

  verbatim_popup_srv(
    "pop",
    title = "boo",
    verbatim_content = reactive("Hello"),
    disabled = disabled
  )
}

shinyApp(ui, server)

Also the case if disabled produces a red error?

@nikolas-burkoff nikolas-burkoff changed the title verbatim popup with shiny validation for disabled verbatim popup with shiny validation or red error for disabled Nov 4, 2022
@nikolas-burkoff
Copy link
Contributor Author

nikolas-burkoff commented Nov 4, 2022

Something like this might work: 😑

verbatim_popup_ui <- function(id, button_label, type = c("button", "link"), ...) {
  checkmate::assert_string(id)
  checkmate::assert_string(button_label)

  ui_function <- switch(match.arg(type),
    "button" = shiny::actionButton,
    "link" = shiny::actionLink,
    stop("Argument 'type' should be 'button' or 'link'")
  )

  ns <- shiny::NS(id)
  ui_args <- list(
    inputId = ns("button"),
    label = button_label
  )


  shiny::tagList(
    shiny::singleton(
      shiny::tags$head(shiny::includeScript(system.file("js/verbatim_popup.js", package = "teal.widgets")))
    ),
    do.call(ui_function, c(ui_args, list(...))),
    # this is dummy output - see the comment in srv
    shiny::uiOutput(ns("disable_controller"), inline = TRUE, style = "font-size:0px")
  )
}

@donyunardi
Copy link
Contributor

I see the same behavior in QQ Plot under tm_g_distribution:

image

Looking at ?validate help info, it does say:

If you use validate() in a reactive(), validation failures will automatically propagate to outputs that use the reactive.

Hiding the message by setting the font-size to 0 definitely works.

@mhallal1
Copy link
Contributor

mhallal1 commented Nov 8, 2022

@nikolas-burkoff I tested out with different options but it seems that setting the font size to 0 in the style is the only working solution for now.

@donyunardi
Copy link
Contributor

donyunardi commented Nov 10, 2022

Acceptance Criteria:

  • Validation error should not appear in Show Warnings and Show R Code button (verbatim_popup_*).

@Polkas Polkas self-assigned this Dec 7, 2022
Polkas added a commit that referenced this issue Dec 9, 2022
closes #102

I simplify the code by placing the observe one module deeper.

Signed-off-by: Maciej Nasinski <nasinski.maciej@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants