Appsilon / shiny.semantic

Shiny support for powerful Fomantic UI library.
http://appsilon.github.io/shiny.semantic
Other
498 stars 96 forks source link

Why single choice checkboxes does not return any value in R shiny.sementic package? #385

Closed DamienGeorges closed 2 years ago

DamienGeorges commented 2 years ago

Hi,

I have to build an app using shiny (and ideally shiny.sementic for it nice and modern design) where my checkboxes choices is updated dynamically (using reactive). But when I have a single choice, my checkbox output is contently NULL unrespective the box is checked or not. Do you know why?

Please see the example bellow:

# Checkbox
library(shiny)
library(shiny.semantic)

ui <- function() {
  shinyUI(
    semanticPage(
      title = "Checkbox example",
      h1("Checkboxes with multiple choices"),
      multiple_checkbox("checkboxes_01", "Select Letters", LETTERS[1:6], selected = "A"),
      p("Selected letters:"),
      textOutput("selected_letters"),
      tags$br(),
      h1("Checkboxes with single choices"),
      multiple_checkbox("checkboxes_02", "Select Letter", LETTERS[1], selected = "A"),
      p("Selected letter:"),
      textOutput("selected_letter")
    )
  )
}

server <- shinyServer(function(input, output) {
  output$selected_letters <- renderText(paste(input$checkboxes_01, collapse = ", "))
  output$selected_letter <- renderText(paste(input$checkboxes_02, collapse = ", "))
})

shinyApp(ui = ui(), server = server)

Screenshot from 2021-10-11 12-16-48

How can I make input$checkboxes_02 return A when the box is checked in this example?

Note: everithing works right when I am having 2 or more choices (see ``checkboxes_01``` in the example)

Thanks!

federiva commented 2 years ago

Hi Damien thanks for using shiny.semantic and for your reproducible example. Your example in my case is working as expected (see gif attached) Peek 2021-10-11 07-40 I don't really know what's going on there, but maybe you can start by restarting your R session with an empty environment and also check which are your R, shiny and shiny.semantic versions?

DamienGeorges commented 2 years ago

Thanks a lot for the quick reply! Unfortunately, just restarting and re-loading the packages does not solve the issue in my case.

Bellow my config

sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora 34 (Workstation Edition)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libflexiblas.so.3.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
 [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] shiny.semantic_0.4.3 shiny_1.7.1         

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7        jquerylib_0.1.4   bslib_0.3.1       pillar_1.6.3      compiler_4.0.5   
 [6] later_1.3.0       tools_4.0.5       digest_0.6.28     jsonlite_1.7.2    lifecycle_1.0.1  
[11] tibble_3.1.5      gtable_0.3.0      pkgconfig_2.0.3   rlang_0.4.11      DBI_1.1.1        
[16] fastmap_1.1.0     dplyr_1.0.7       sass_0.4.0        generics_0.1.0    vctrs_0.3.8      
[21] htmlwidgets_1.5.4 grid_4.0.5        tidyselect_1.1.1  glue_1.4.2        R6_2.5.1         
[26] fansi_0.5.0       ggplot2_3.3.5     purrr_0.3.4       magrittr_2.0.1    scales_1.1.1     
[31] promises_1.2.0.1  ellipsis_0.3.2    htmltools_0.5.2   rsconnect_0.8.24  assertthat_0.2.1 
[36] mime_0.12         colorspace_2.0-2  xtable_1.8-4      httpuv_1.6.3      utf8_1.2.2       
[41] munsell_0.5.0     cachem_1.0.6      crayon_1.4.1

Could you please share me yours so I can give it a try?

Thanks again

DamienGeorges commented 2 years ago

Well it seems to be an error linked with the dev version of shiny.semanticavailable on github (0.4.3). Re-installing cran version (0.4.2) solve the issue. Thanks for putting me on the right direction! And maybe something to have a keep in mind for the future release of the package.

All the best, Damien

DamienGeorges commented 2 years ago

Hi,

Sorry to reopen this topic but the bugfix proporsed by @ashbaldry (Thanks!) has not been added to the develop (nor master) version of shiny.semantic. Any chance to have it done in a near future?

All the best, Damien