From e830d4da0ac76bb712e56257ad2e1953c98b05f8 Mon Sep 17 00:00:00 2001 From: Mauro Masiero Date: Wed, 20 Mar 2024 17:03:56 +0100 Subject: [PATCH] add shinyvalidate bug example; simplify REPRO --- inst/app/app-dev.R | 63 ++++++++++------------------------------------ 1 file changed, 13 insertions(+), 50 deletions(-) diff --git a/inst/app/app-dev.R b/inst/app/app-dev.R index 8603030..3ccc942 100644 --- a/inst/app/app-dev.R +++ b/inst/app/app-dev.R @@ -2,13 +2,6 @@ library(shiny) library(wizardR) library(bslib) library(shiny) -library(htmltools) -library(plotly) - -plotly_widget <- plotly::plot_ly(x = diamonds$cut) %>% - config(displayModeBar = FALSE) %>% - layout(margin = list(t = 0, b = 0, l = 0, r = 0)) - ui <- fluidPage( "wizardR demo", @@ -27,50 +20,9 @@ ui <- fluidPage( shiny::actionButton("unlock_wizard", "unLock") ), wizard_step( - step_title = "Numeric input", - shiny::actionButton("reset_wizard", "Reset"), - shiny::numericInput("number", "Select a number", value = 30, min = 20, max = 100) - ), - wizard_step( - bslib::layout_columns( - bslib::card( - full_screen = TRUE, - card_header("A filling plot"), - card_body(plotly_widget) - ),card( - full_screen = TRUE, - card_header("A filling plot"), - card_body(plotly_widget) - ),card( - full_screen = TRUE, - card_header("A filling plot"), - card_body(plotly_widget) - ),card( - full_screen = TRUE, - card_header("A filling plot"), - card_body(plotly_widget) + step_title = "Try to lock wizard after shinyvalidate activated", + shiny::textInput("login_email", "Enter some text and lock wizard in step 1") ) - ), - bslib::layout_columns( - bslib::card( - full_screen = TRUE, - card_header("A filling plot"), - card_body(plotly_widget) - ),card( - full_screen = TRUE, - card_header("A filling plot"), - card_body(plotly_widget) - ),card( - full_screen = TRUE, - card_header("A filling plot"), - card_body(plotly_widget) - ),card( - full_screen = TRUE, - card_header("A filling plot"), - card_body(plotly_widget) - ) - ) - ) ) ) @@ -106,6 +58,17 @@ server <- function(input, output, session) { print("reset wizard") wizardR::reset("my_modal") }) + + observeEvent(input$login_email, { + # validate text input + req(input$login_email) + print("text input changed") + print(input$login_email) + iv <- shinyvalidate::InputValidator$new() + iv$add_rule("login_email", shinyvalidate::sv_required()) + iv$add_rule("login_email", shinyvalidate::sv_email()) + iv$enable() + }) } shinyApp(ui, server)