Consider the following code that sets the background of the numeric input widget to red upon invalid input:
library(shiny)
ui <- shinyUI(
fluidPage(
column(12,
tags$style(HTML("input:invalid {background-color: #FFCCCC;}")),
numericInput("test", h5("Test value:"), value = 6, min = 0, max = 10, step = 2, width = '200px')
)
)
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
If the user enters '-1', or '11', or '4', then the code works as expected (invalid for the first two examples, valid for the third example).
However, observe what happens when an odd number is entered that is between the min and max values. The code thinks the input is invalid. But notice that the 'step' value to the numeric input is even, suggesting that the code mistakenly thinks that a correct number must not only be between 0 and 10, but also a multiple of 2.
To prove this, remove the 'step' option, or change it to 1, and then any (integer-valued) input between 0 and 10 will work.
Is this a bug, and is there a workaround (that is, so that I can maintain the 'step' value but still allow any and all numbers between the min and max), or am I missing something here?
I was under the impression that the 'step' value simply controlled the amount by which the arrows increment or decrement input, not for the purposes of input validation.