jrowen / rhandsontable

A htmlwidgets implementation of Handsontable.js
http://jrowen.github.io/rhandsontable/
Other
380 stars 147 forks source link

Bug `type = "dropdown"` with table having only one row #388

Closed stla closed 2 years ago

stla commented 2 years ago

Hello,

When I use type = "dropdown" in hot_col with a table having a single row, the dropdowns do not work. I tried in the RStudio browser as well as in an ordinary browser (Vivaldi and Chrome).

library(rhandsontable)

DF = data.frame(val = 1, bool = TRUE, big = LETTERS[1],
                small = letters[1],
                stringsAsFactors = FALSE)

rhandsontable(DF, rowHeaders = NULL) %>%
  hot_col(col = "big", type = "dropdown", source = LETTERS[1:2]) %>%
  hot_col(col = "small", type = "dropdown", source = letters)

I'm surprised I didn't notice that before.

> xfun::session_info()
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363), RStudio 1.4.1717

Locale:
  LC_COLLATE=French_Belgium.1252  LC_CTYPE=French_Belgium.1252   
  LC_MONETARY=French_Belgium.1252 LC_NUMERIC=C                   
  LC_TIME=French_Belgium.1252    

Package version:
  base64enc_0.1.3     BH_1.75.0.0         bslib_0.2.5         cachem_1.0.4       
  commonmark_1.7      compiler_3.6.2      crayon_1.3.4        digest_0.6.27      
  ellipsis_0.3.2      fastmap_1.0.1       fs_1.5.0            glue_1.4.2         
  graphics_3.6.2      grDevices_3.6.2     htmltools_0.5.1.1   htmlwidgets_1.5.3  
  httpuv_1.6.1        jquerylib_0.1.4     jsonlite_1.7.2      later_1.0.0        
  lifecycle_1.0.0     magrittr_2.0.1      methods_3.6.2       mime_0.8           
  promises_1.1.0      R6_2.4.1            rappdirs_0.3.3      Rcpp_1.0.6         
  rhandsontable_0.3.8 rlang_0.4.10        sass_0.4.0          shiny_1.6.0        
  sourcetools_0.1.7   stats_3.6.2         tools_3.6.2         utils_3.6.2        
  withr_2.4.2         xfun_0.22           xtable_1.8-4        yaml_2.2.0  

I also tested with R 4.1.0.

That does not work too with a table having only two rows.

stla commented 2 years ago

I've found a solution!

rhandsontable(DF, rowHeaders = NULL, overflow = "visible")

Or set an height.