Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upNumericInput min, max values disrespect on keyboard-input #1022
Comments
|
Here's what I get with the first chunk of code: library(shiny)
ui <- pageWithSidebar(
headerPanel('Download Example'),
sidebarPanel(
numericInput("n", "N:", min = 0, max = 100, value = 50)
),
mainPanel()
)
server <- function(input, output, session) {
}
shinyApp(ui, server) |
|
It's pretty mysterious that if you run instead the second chunk of code (i.e. put a slider input before the numeric input), the messages disappear... Looking into it. library(shiny)
ui <- pageWithSidebar(
headerPanel('Download Example'),
sidebarPanel(
sliderInput("sampSize", "Sample Size",min = 2, max = 20, step = 2, value = 10),
numericInput("n", "N:", min = 0, max = 100, value = 50)
),
mainPanel()
)
server <- function(input, output, session) {
}
shinyApp(ui, server) |
|
Also interesting is that this does not happen when we have a more stripped-down page. E.g. the following app does not result in any tooltips or pop overs: library(shiny)
ui <- fluidPage(
numericInput("n", "N:", min = 0, max = 100, value = 50)
)
server <- function(input, output, session) {}
shinyApp(ui, server) |
|
Take a look at cleave JS library: https://nosir.github.io/cleave.js/. (Recentely implemented for Shiny by @carlganz here) |
|
@bborgesr it works as expected. :) TLDR; I prepared the following html snippet to reproduce a few use cases.
The rule is the following one: there is no way to trigger the native tooltips other than submitting the form. As stated in W3C Specs, when there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form. Back to the shiny examples. This snippet displays correctly the native validation tooltip (W3C 8.2, see above):
This snippet doesn't display correctly the native validation tooltip, because there is not a submit button (or input):
This snippet doesn't display correctly the native validation tooltip, because one single-line text input field
So I tried to add a submit button, but the native validation tooltip is not displayed.
This is a bug and it is due to the preventDefault call in Line 91 in a0b917a I would modify that code adding
If it makes sense, I would prepare a PR with the above change, closing this issue. About the use of an external lib to improve the client validation, I suggest to open a new issue to collect feedbacks, comments and suggestions. |



I know this issue was opened before, but I still think this is a rather mixed and curois behaviour. When I have inside a shiny app just one numericInput panel and nothing else, if I try to write integer bigger than max I get an error message (in Chrome).
But if I have something else before the numericInput, that error message no longer appears.
library(shiny)
On other browsers it also doesn't appear. Is this a desirev behaviour or strange outcome?