-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
simplify the verbatim pop up #127
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR doesn't close #102 as validation error is still rendered on the button
main | This branch |
---|---|
pkgload::load_all("teal.widgets")
library(teal.code)
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)
R/verbatim_popup.R
Outdated
@@ -61,7 +57,9 @@ verbatim_popup_ui <- function(id, button_label, type = c("button", "link"), ...) | |||
#' @param style (`logical(1)`) whether to style the `verbatim_content` using `styler::style_text`. | |||
#' If `verbatim_content` is a `condition` or `reactive` holding `condition` then this argument is ignored | |||
#' @param disabled (`reactive(1)`) the `shiny` reactive value holding a `logical`. The popup button is disabled | |||
#' when the flag is `TRUE` and enabled otherwise | |||
#' when the flag is `TRUE` and enabled otherwise. | |||
#' Please take into account that `shinyjs` is the dependency for this functionality so the `shinyjs::useShinyjs()` call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just include useShinyjs() in the UI of this element. It's a singleton so multiple calls shouldn't make a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Polkas what about this? Would you agree to include shinyjs::useShinyjs
so we don't need to notify anyone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the package has the shinyjs dependency so not including it will NOT reduce the dependency for sb who want to use this functionality.
Then I agree with you that adding shinyjs::useShinyjs
it is a good move.
Signed-off-by: Maciej Nasinski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
closes #102
I simplify the code by placing the observe one module deeper.
I added a comment about
shinyjs::useShinyjs()
needed for disabled functionality, It was always needed but not documented.Example app: