Chriss Paul
Chriss Paul

Reputation: 1101

Increment in Shiny numericInput is 2 despite step = 1 in macOS Catalina

Assume you have a numericInput in your Shiny application.

library(shiny)
ui <- fluidPage(numericInput(
    "input",
    "n",
    value = 2,
    min = 2,
    max = 10,
    step = 1
))
shinyApp(ui, function(input, output) {
    observe({
        str(input$hadley)
    })
})

If you run this application and click the up or down arrow within the numericInput box, it will increment by steps of twice the value in step. Did I miss something when I use numericInput?

Session info

R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.6.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5       crayon_1.3.4     digest_0.6.27    withr_2.3.0      later_1.1.0.1    mime_0.9        
 [7] R6_2.5.0         jsonlite_1.7.1   lifecycle_1.0.0  xtable_1.8-4     magrittr_2.0.1   cachem_1.0.4    
[13] rlang_0.4.10     rstudioapi_0.13  promises_1.2.0.1 jquerylib_0.1.3  bslib_0.2.4      ellipsis_0.3.1  
[19] tools_4.0.3      httpuv_1.5.5     fastmap_1.1.0    compiler_4.0.3   htmltools_0.5.1  sass_0.3.1      

Upvotes: 0

Views: 453

Answers (1)

Chriss Paul
Chriss Paul

Reputation: 1101

After some research I found that it has been reported a bug and seems this is only an issue in macOS.

One of the solutions mentioned by NickPyll (which is, of course, obvious) is to set step to half your actual step. At least for now it works in my application.

Upvotes: 0

Related Questions