I'm developing a shiny app using the great shinyglide package to create a modal for the user to enter some information. The problem is that on the first screen I would need to create a conditional so that the user must enter a value in order to proceed. Unfortunately, I can't use the next_condition
command on the first screen, seems to only work from the second screen.
When I click the "Next" button and then return to the first screen using the "Back" button, the condition works and I can't go forward until I click in at least one option, but the first time it does not work that way.
Is this behavior normal? Is it possible to set another type of condition in this case?
I made a small example to show the problem:
library(shiny)
library(shinyglide)
ui <- fixedPage(
titlePanel("shinyglide modal example"),
sidebarLayout(
sidebarPanel(
p('Hello World')
),
mainPanel()
)
)
server <- function(input, output, session) {
modal_controls <- glideControls(
list(prevButton(),
firstButton(class = "btn btn-danger",`data-dismiss`="modal","No, thanks !")),
list(nextButton(),
lastButton(class = "btn btn-success",`data-dismiss`="modal","Done"))
)
glide_modal <- modalDialog(
title = "Startup assistant",easyClose = FALSE,footer = NULL,
glide(custom_controls = modal_controls,
screen(next_condition="input.options.length > 0",
p("First, please select an option"),
checkboxGroupInput("options", "Options", choices=c('a','b','c'),selected=NULL)
),
screen(p("Next, please select a number"),
numericInput("number", "Number", value = 1, min = 0)
),
screen(p("Thanks, we're all set !"))
)
)
showModal(glide_modal)
}
shinyApp(ui, server)