Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug: styleRow() appears to do nothing when viewed in browser #1143

Open
BajczA475 opened this issue Jun 12, 2024 · 0 comments
Open

Comments

@BajczA475
Copy link

BajczA475 commented Jun 12, 2024

Problem: When using formatStyle() with styleRow() to conditionally style rows, I am getting inconsistent behavior. When viewing in the RStudio viewer, the code works as intended; when viewed in the browser with the app running, it doesn't (as if the code is doing nothing)

Reproducible example: 
### LOAD PACKAGES
library(shiny)
library(dplyr)
library(DT)
library(gapminder)

### LOAD DATA SETS 
gap = gapminder

ui = fluidPage(
  
  dataTableOutput("basic_table")
  
)

server = function(input, output, session) {
  
  output$basic_table = renderDT({
###
  gap %>% 
    datatable() %>% 
    formatStyle(columns = names(gap),
                backgroundColor = styleRow(
                  which(gap$lifeExp > 70), "lightpink"
                ))
###
  })
  
}

shinyApp(ui, server)
If I run the code between the ###s at the Console and examine in my Viewer, I can confirm the code works correctly, but when launching the app, I don't get any conditional formatting. My browser is Edge (up to date). I have cleared my cache, used ctrl+F5, and examined the devtools--no issues/changes. Edit: I'll also note that I have no custom CSS being applied to this code; only whatever might be coming along by default. 

I'm running latest version of RStudio but R 4.3.3 (4.4.0 has been buggy for me). Session info:

R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631), RStudio 2024.4.2.764

Locale:
  LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
  LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
  LC_TIME=English_United States.utf8    

Package version:
  base64enc_0.1.3   bslib_0.7.0       cachem_1.0.8      cli_3.6.2        
  crosstalk_1.2.1   digest_0.6.35     DT_0.33           evaluate_0.23    
  fastmap_1.1.1     fontawesome_0.5.2 fs_1.6.4          glue_1.7.0       
  graphics_4.3.3    grDevices_4.3.3   highr_0.10        htmltools_0.5.8.1
  htmlwidgets_1.6.4 httpuv_1.6.15     jquerylib_0.1.4   jsonlite_1.8.8   
  knitr_1.46        later_1.3.2       lazyeval_0.2.2    lifecycle_1.0.4  
  magrittr_2.0.3    memoise_2.0.1     methods_4.3.3     mime_0.12        
  promises_1.3.0    R6_2.5.1          rappdirs_0.3.3    Rcpp_1.0.12      
  rlang_1.1.3       rmarkdown_2.26    sass_0.4.9        stats_4.3.3      
  tinytex_0.50      tools_4.3.3       utils_4.3.3       xfun_0.43        
  yaml_2.3.8       




<!--
Please keep the portion below in your issue. Your issue will be closed if any of the boxes is not checked. In certain (rare) cases, you may be exempted if you give a brief explanation (e.g., you are only making a suggestion for improvement). Thanks!
-->

---

By filing an issue to this repo, I promise that

- [X ] I have fully read the issue guide at https://yihui.org/issue/.
- [X ] I have provided the necessary information about my issue.
    - If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    - If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included `xfun::session_info('DT')`. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: `remotes::install_github('rstudio/DT')`.
    - If I have posted the same issue elsewhere, I have also mentioned it in this issue.
- [ X] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant