gt icon indicating copy to clipboard operation
gt copied to clipboard

"Shared input/output ID" error in a Shiny app

Open jacciz opened this issue 7 months ago • 4 comments
trafficstars

Prework

Description

When using {gt}, I get errors in the browser saying:

  • Shared input/output ID was found - The following ID was used for more than one input/output: "demo_table": 1 input and 1 output
  • TypeError: Cannot read properties of undefined (reading 'get').

The shiny app still runs and renders the table. I installed v0.11.1 and this issue DID NOT exist.

Reproducible example

library(shiny)
library(gt)
ui <- fluidPage(
  gt_output("demo_table")
)

server <- function(input, output, session) {
  output$demo_table <- render_gt({
    mtcars |>
      head(10) |>
      gt()
  })
}

shinyApp(ui, server)

Expected result

No error. Table still renders.

Session info

R version 4.4.1 (2024-06-14 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: America/New_York tzcode source: internal

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

other attached packages: [1] bslib_0.9.0 gt_1.0.0 shiny_1.10.0 devtools_2.4.5 usethis_3.1.0

loaded via a namespace (and not attached): [1] jsonlite_2.0.0 miniUI_0.1.1.1 dplyr_1.1.4 compiler_4.4.1 promises_1.3.2
[6] tidyselect_1.2.1 Rcpp_1.0.14 xml2_1.3.6 jquerylib_0.1.4 later_1.4.2
[11] fastmap_1.2.0 mime_0.13 R6_2.6.1 generics_0.1.3 htmlwidgets_1.6.4 [16] tibble_3.2.1 profvis_0.4.0 pillar_1.10.2 rlang_1.1.4 cachem_1.1.0
[21] httpuv_1.6.16 sass_0.4.10 fs_1.6.6 pkgload_1.4.0 memoise_2.0.1
[26] cli_3.6.3 withr_3.0.2 magrittr_2.0.3 digest_0.6.37 rstudioapi_0.17.1 [31] xtable_1.8-4 remotes_2.5.0 lifecycle_1.0.4 vctrs_0.6.5 glue_1.8.0
[36] urlchecker_1.0.1 sessioninfo_1.2.3 rsconnect_1.3.4 pkgbuild_1.4.6 purrr_1.0.4
[41] tools_4.4.1 pkgconfig_2.0.3 ellipsis_0.3.2 htmltools_0.5.8.1

jacciz avatar Apr 18 '25 13:04 jacciz

Removing the class argument fixes this problem:.

gt_output <- function(outputId) {
  # Ensure that the shiny package is available
  rlang::check_installed("shiny", "to use `gt_output()`.")

  shiny::htmlOutput(outputId, class = "gt_shiny")
}

jacciz avatar Apr 18 '25 22:04 jacciz

@jonthegeek Do you have an idea here?

According to git blame, you have added this in https://github.com/rstudio/gt/commit/e1bb50231fddb566b6f2a5ebb819d04abe6bc4a5 in #1909.

https://github.com/rstudio/gt/blob/d84be8fbb6c491195e52172b58533482a8be2c06/R/shiny.R#L286-L292

olivroy avatar Apr 22 '25 17:04 olivroy

@jonthegeek Do you have an idea here?

According to git blame, you have added this in e1bb502 in #1909.

I haven't seen an actual impact from the warning. I'll take a look to see if there's a logical way to deal with it. You create both the input (where you click on the table) and the output (what is in the table) with the same call, but I think there's precedence for adding something like -selected to that ID for the input half, so I can give that a try soon. I have jury duty this week or I'd get right on it!

jonthegeek avatar Apr 23 '25 10:04 jonthegeek

@jonthegeek I don't see an actual impact, either. I'm tinkering with your suggestion but am new to js. Thank you for your work on this (and DSLC!)

jacciz avatar Apr 23 '25 22:04 jacciz

I have the same problem. It doesn't seem to impact anything at the moment, it's just a little annoying

Upipa avatar Sep 02 '25 14:09 Upipa