Swechhya / excelR

An Interface to 'jExcel.js' Library
https://swechhya.github.io/excelR/
Other
152 stars 19 forks source link

input object corresponding to renderExcel output not available. #99

Closed lanceupton closed 2 years ago

lanceupton commented 2 years ago

Great package! The development version offers a lot of functionality that I need in my shiny apps, however I noticed an issue recently (described below) that I wonder may be related to a recent development version or if I'm doing something completely wrong :(

Describe the bug The input object corresponding to renderExcel output is always NULL.

To Reproduce See MRE below.

Expected behavior input$tab should update when output$tab updates. But, it doesn't seem to so when you click "Add Letter", a new letter is being added to NULL so only the new letter appears in the table.

Desktop (please complete the following information):

> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux

Matrix products: default
BLAS/LAPACK: /lrlhps/apps/intel/intel-2020/compilers_and_libraries_2020.0.166/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so

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

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

other attached packages:
[1] excelR_0.4.0 shiny_1.7.1 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6        bslib_0.3.1       compiler_4.0.3    later_1.1.0.1     jquerylib_0.1.4  
 [6] remotes_2.2.0     tools_4.0.3       testthat_3.0.0    digest_0.6.27     pkgload_1.1.0    
[11] jsonlite_1.7.2    lifecycle_1.0.0   rlang_0.4.12      rstudioapi_0.13   cli_2.5.0        
[16] yaml_2.2.1        golem_0.3.1       xfun_0.23         fastmap_1.1.0     xml2_1.3.2       
[21] knitr_1.36        stringr_1.4.0     roxygen2_7.1.1    withr_2.4.2       desc_1.2.0       
[26] htmlwidgets_1.5.2 sass_0.4.0        fs_1.5.0          attempt_0.3.1     rprojroot_2.0.2  
[31] glue_1.5.0        R6_2.5.0          purrr_0.3.4       magrittr_2.0.1    dockerfiler_0.1.3
[36] usethis_1.6.3     promises_1.1.1    ellipsis_0.3.2    htmltools_0.5.2   rsconnect_0.8.25 
[41] assertthat_0.2.1  mime_0.9          xtable_1.8-4      renv_0.14.0       httpuv_1.5.4     
[46] config_0.3.1      stringi_1.5.3     cachem_1.0.5      crayon_1.4.1    

Possibly related: I install this package via renv::install("Swechhya/excelR")

Additional context

MRE:

library(shiny)
library(excelR)

ui <- fluidPage(
  actionButton("browser", "Browser"),
  actionButton("btn_add", "Add Letter"),
  excelOutput("tab")
)

server <- function(input, output, session) {

  # Initialize source for tab
  all_letters <- reactiveVal()

  # Add a letter to the source when "btn_add" is clicked
  observeEvent(input$btn_add, {
    current <- excel_to_R(input$tab)
    print(current)
    new <- data.frame(x = sample(letters, 1))
    all <- rbind(current, new)
    all_letters(all)
  })

  # Table output
  output$tab <- renderExcel(excelTable(all_letters()))

  # Browser
  observeEvent(input$browser, {
    print(input$tab)
    browser()
  })

}

shinyApp(ui, server)
analytichealth commented 2 years ago

We have the same issue, the output object will only contain changes made manually to the table. It will not include changes made programmatically. Any tips here would be appreciated. Thanks

Swechhya commented 2 years ago

@lanceupton @analytichealth Please feel free to open this if the issue persists in the latest development version.

analytichealth commented 2 years ago

Thanks @Swechhya, working as expected for me.

lanceupton commented 2 years ago

Confirmed, works great. Thank you!