rstudio / htmltools

Tools for HTML generation and output
https://rstudio.github.io/htmltools/
215 stars 68 forks source link

v0.4.0 incompatible with shiny / DT renderDataTable #143

Open kkrismer opened 4 years ago

kkrismer commented 4 years ago

Dear htmltools developers,

it seems that v0.4.0 doesn't play nicely with the renderDataTable function from shiny / DT.

Specifically, htmltools 0.4.0 causes character columns of DT tables in shiny apps to be rendered incorrectly (i.e., only the first character is shown per row and column). Numeric columns are not affected.

Minimal working example:

library(shiny)

ui <- fluidPage(
  dataTableOutput("table")
)

server <- function(input, output) {
  output$table <- renderDataTable(
    {
      data.frame(integer_column = c(10:20),
                 character_column = as.character(c(10:20)))
    }
  )
}

shinyApp(ui, server)

This example code properly displays the DT table with htmltools 0.3.6, but not with htmltools 0.4.0. Tested on Windows 10 and Ubuntu 16.04.6, both running R 3.6.1.

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

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

other attached packages:
[1] shiny_1.3.2

loaded via a namespace (and not attached):
 [1] compiler_3.6.1  magrittr_1.5    R6_2.4.0        promises_1.1.0  later_1.0.0     htmltools_0.4.0 tools_3.6.1    
 [8] Rcpp_1.0.2      jsonlite_1.6    digest_0.6.21   xtable_1.8-4    httpuv_1.5.2    mime_0.7        rlang_0.4.0  

Cheers, Konstantin

cpsievert commented 4 years ago

Duplicate of https://github.com/rstudio/shiny/issues/2653.

philibe commented 4 years ago

I have not this problem with htmltools_0.4.0 at home, but I've seen this strange thing at work with a source not by me, and I think I tried to workaround this issue with success by adding DT::datatable.

edit 2: I reproduce the issue now with unloading DT !!

In other words:

But I cannot reproduce at home, and at work I'm not sure at 100% this was this issue, because when the strange issue was solved, I passed to other thing and continue to make changes.

edit 1: Like @cpsievert said in rstudio/shiny#2653, the DT:: was not in initial source.

edit 2: I reproduce the issue now with unloading DT !!

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252 LC_NUMERIC=C                  
[5] LC_TIME=French_France.1252    

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

other attached packages:
[1] shiny_1.4.0

loaded via a namespace (and not attached):
 [1] compiler_3.4.4  fastmap_1.0.1   magrittr_1.5    R6_2.4.0        promises_1.1.0  later_0.8.0     htmltools_0.4.0 tools_3.4.4    
 [9] Rcpp_1.0.1      jsonlite_1.6    digest_0.6.18   xtable_1.8-4    httpuv_1.5.2    mime_0.6        rlang_0.4.0    
philibe commented 4 years ago

@nteetor said in rstudio/shiny#2676

can you open your browser's console to see if there are any errors ?

I have many warnings in less/css. But not in js.

warnings with Firefox 69.0.1 ``` GEThttp://127.0.0.1:6126/ [HTTP/1.1 200 OK 39ms] GEThttp://127.0.0.1:6126/shared/shiny.css [HTTP/1.1 200 OK 8ms] GEThttp://127.0.0.1:6126/shared/json2-min.js [HTTP/1.1 304 Not Modified 8ms] GEThttp://127.0.0.1:6126/shared/jquery.min.js [HTTP/1.1 304 Not Modified 8ms] GEThttp://127.0.0.1:6126/shared/shiny.min.js [HTTP/1.1 304 Not Modified 8ms] GEThttp://127.0.0.1:6126/shared/datatables/js/jquery.dataTables.min.js [HTTP/1.1 304 Not Modified 1ms] GEThttp://127.0.0.1:6126/shared/datatables/css/dataTables.bootstrap.css [HTTP/1.1 304 Not Modified 4ms] GEThttp://127.0.0.1:6126/shared/datatables/css/dataTables.extra.css [HTTP/1.1 304 Not Modified 4ms] GEThttp://127.0.0.1:6126/shared/datatables/js/dataTables.bootstrap.js [HTTP/1.1 304 Not Modified 3ms] GEThttp://127.0.0.1:6126/shared/bootstrap/css/bootstrap.min.css [HTTP/1.1 304 Not Modified 1ms] GEThttp://127.0.0.1:6126/shared/bootstrap/js/bootstrap.min.js [HTTP/1.1 304 Not Modified 2ms] GEThttp://127.0.0.1:6126/shared/bootstrap/shim/html5shiv.min.js [HTTP/1.1 304 Not Modified 1ms] GEThttp://127.0.0.1:6126/shared/bootstrap/shim/respond.min.js [HTTP/1.1 304 Not Modified 1ms] Erreur d’analyse de la valeur pour « transition ». Déclaration abandonnée. shiny.css:113:17 Erreur d’analyse de la valeur pour « -webkit-text-size-adjust ». Déclaration abandonnée. normalize.less:14:2 Propriété « -moz-text-decoration » inconnue. Déclaration abandonnée. normalize.less:116:2 Propriété « orphans » inconnue. Déclaration abandonnée. print.less:63:4 Propriété « widows » inconnue. Déclaration abandonnée. print.less:66:2 Propriété « -moz-osx-font-smoothing » inconnue. Déclaration abandonnée. glyphicons.less:33:2 Erreur d’analyse de la valeur pour « outline ». Déclaration abandonnée. tab-focus.less:7:2 Erreur d’analyse de la valeur pour « outline ». Déclaration abandonnée. tab-focus.less:7:2 Pseudo-classe ou pseudo-élément « -ms-input-placeholder » inconnu. Jeu de règles ignoré suite à un mauvais sélecteur. vendor-prefixes.less:109:2 Pseudo-classe ou pseudo-élément « -ms-expand » inconnu. Jeu de règles ignoré suite à un mauvais sélecteur. forms.less:157:2 Erreur d’analyse de la valeur pour « margin-top ». Déclaration abandonnée. forms.less:259:2 Erreur d’analyse de la valeur pour « outline ». Déclaration abandonnée. tab-focus.less:7:2 « none », URL, ou fonction filter attendu, mais « alpha( » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. opacity.less:5:2 « none », URL, ou fonction filter attendu, mais « progid » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. reset-filter.less:7:2 Règle « at » non reconnue ou erreur d’analyse de la règle « @-o-keyframes ». progress-bars.less:18 Propriété « zoom » inconnue. Déclaration abandonnée. media.less:16 « none », URL, ou fonction filter attendu, mais « alpha( » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. opacity.less:5:2 « none », URL, ou fonction filter attendu, mais « alpha( » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. opacity.less:5:2 « none », URL, ou fonction filter attendu, mais « alpha( » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. opacity.less:5:2 « none », URL, ou fonction filter attendu, mais « alpha( » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. opacity.less:5:2 « none », URL, ou fonction filter attendu, mais « alpha( » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. opacity.less:5:2 « none », URL, ou fonction filter attendu, mais « alpha( » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. opacity.less:5:2 Nom de fonctionnalité média attendue, mais « transform-3d » trouvé. carousel.less:31:4 « none », URL, ou fonction filter attendu, mais « alpha( » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. opacity.less:5:2 « none », URL, ou fonction filter attendu, mais « progid » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. gradients.less:13:4 « none », URL, ou fonction filter attendu, mais « progid » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. gradients.less:13:4 « none », URL, ou fonction filter attendu, mais « alpha( » trouvé. Erreur d’analyse de la valeur pour « filter ». Déclaration abandonnée. opacity.less:5:2 Règle « at » non reconnue ou erreur d’analyse de la règle « @-ms-viewport ». responsive-utilities.less:24:2 GEThttp://127.0.0.1:6126/websocket/ [HTTP/1.1 101 Switching Protocols 10ms] GEThttp://127.0.0.1:6126/favicon.ico GEThttp://127.0.0.1:6126/shared/datatables/images/sort_both.png [HTTP/1.1 200 OK 1ms] XHRPOSThttp://127.0.0.1:6126/session/f1ba481caa08b23e4d36037f2e6c750b/dataobj/table?w=&nonce=20861ce79ca50826 [HTTP/1.1 200 OK 18ms] ```
Answer of XHRPOSThttp://127.0.0.1:6126/session/f..../dataobj/table... with Firefox 69.0.1 ``` :1,"recordsTotal":11,"recordsFiltered":11,"data":["10","11","12","13","14","15","16","17","18","19","20","10","11","12","13","14","15","16","17","18","19","20"]} ```
Stack trace of XHRPOSThttp://127.0.0.1:6126/session/f..../dataobj/table... with Firefox 69.0.1 ``` send http://127.0.0.1:6126/shared/jquery.min.js:2:81476 ajax http://127.0.0.1:6126/shared/jquery.min.js:2:77295 ra http://127.0.0.1:6126/shared/datatables/js/jquery.dataTables.min.js:33:380 kb http://127.0.0.1:6126/shared/datatables/js/jquery.dataTables.min.js:33:466 M http://127.0.0.1:6126/shared/datatables/js/jquery.dataTables.min.js:26:186 N http://127.0.0.1:6126/shared/datatables/js/jquery.dataTables.min.js:28:173 ga http://127.0.0.1:6126/shared/datatables/js/jquery.dataTables.min.js:45:346 o/< http://127.0.0.1:6126/shared/datatables/js/jquery.dataTables.min.js:92:489 each http://127.0.0.1:6126/shared/jquery.min.js:2:2777 each http://127.0.0.1:6126/shared/jquery.min.js:2:1419 o http://127.0.0.1:6126/shared/datatables/js/jquery.dataTables.min.js:82:283 O/h.fn.DataTable http://127.0.0.1:6126/shared/datatables/js/jquery.dataTables.min.js:157:441 renderValue output_binding_datatable.js:46:41 this.onValueChange output_binding.js:16:9 this.onValueChange output_binding_adapter.js:21:17 this.receiveOutput shinyapp.js:332:14 shinyapp.js:544:13 this._sendMessagesToHandlers shinyapp.js:529:26 this.dispatchMessage shinyapp.js:515:9 this.createSocket/c.onmessage shinyapp.js:112:11 ```
wch commented 4 years ago

This should be fixed in the development version of Shiny, which you can install with:

devtools::install_github("rstudio/shiny")

But it would be better to use DT::renderDataTable and DT::dataTableOutput, since the DT package has more features.

jamesdalg commented 4 years ago

This should be fixed in the development version of Shiny, which you can install with:

devtools::install_github("rstudio/shiny")

But it would be better to use DT::renderDataTable and DT::dataTableOutput, since the DT package has more features.

I have tested this on my package and note that the renderDataTable issues persist with 0.4.0.9001, exactly as mentioned, with the one character columns exactly as described. installing version 1.3.2 of shiny and version 0.3.6 fixes the problem. After doing some extensive debugging, I realize this is happening within the renderDataTable function. It must have to do with some change between 0.3.6 and 0.4.0 in htmltools. Is there any knowledge of which function in htmltools is likely causing this? Perhaps I can do some investigative work here.