Skip to content

Commit

Permalink
add shinyvalidate bug example; simplify REPRO
Browse files Browse the repository at this point in the history
  • Loading branch information
mauromiguelm committed Mar 20, 2024
1 parent 0402dc0 commit e830d4d
Showing 1 changed file with 13 additions and 50 deletions.
63 changes: 13 additions & 50 deletions inst/app/app-dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
)
)
)
)
)

Expand Down Expand Up @@ -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)

0 comments on commit e830d4d

Please sign in to comment.