Skip to content

shinydashboard::updateTabItems not matching shiny::updateTabsetPanel #397

Closed
@Mosk915

Description

@Mosk915

According to this line, the function updateTabItems is exactly the same function as shiny::updateTabsetPanel.

updateTabItems <- shiny::updateTabsetPanel

The problem is that if the function shiny::updateTabsetPanel were to change, which it did when going from version 1.5.0 to version 1.6.0 of shiny, the function updateTabItems would not also change since it is set at the time the package is compiled. This is problematic when using an renv package cache or when deploying content to Posit Connect which also uses a package cache since there is only one installation of a given version of a package.

This can result in unexpected behavior, where the two function definitions will not match:

> shiny::updateTabsetPanel
function (session = getDefaultReactiveDomain(), inputId, selected = NULL) 
{
    validate_session_object(session)
    message <- dropNulls(list(value = selected))
    session$sendInputMessage(inputId, message)
}
> shinydashboard::updateTabItems
function (session, inputId, selected = NULL) 
{
    message <- dropNulls(list(value = selected))
    session$sendInputMessage(inputId, message)
}

Here is a complete set of steps for how to reproduce the issue in an R project.

  1. Create a project in RStudio or Workbench with renv enabled. Set the renv setting use.cache to false.

  2. Restart R.

  3. Install devtools
    install.packages("devtools", repos = "cran.rstudio.com")

  4. Restart R.

  5. Install shiny 1.5.0
    devtools::install_version("shiny", "1.5.0", repos = "cran.rstudio.com")

  6. Restart R.

  7. Verify shiny::updateTabsetPanel does not have the default set for session in the function definition.

  8. Install shinydashboard 0.7.1. Don’t upgrade any other packages when prompted.
    devtools::install_version("shinydashboard", "0.7.1", repos = "cran.rstudio.com")

  9. Restart R.

  10. Verify shinydashboard::updateTabItems does not have the default set for session in the function definition.

  11. Restart R.

  12. Install shiny 1.6.0
    devtools::install_version("shiny", "1.6.0", repos = "cran.rstudio.com")

  13. Restart R.

  14. Verify shiny::updateTabsetPanel does have the default set for session in the function definition.

  15. Verify shinydashboard::updateTabItems still does not have the default set for session in the function definition.

  16. Restart R.

  17. Reinstall shinydashboard 0.7.1. Don’t upgrade any other packages when prompted.
    devtools::install_version("shinydashboard", "0.7.1", repos = "cran.rstudio.com")

  18. Restart R.

  19. Verify shinydashboard::updateTabItems now does have the default set for session in the function definition.

Perhaps a better way to implement the function would be as follows:

updateTabItems <- function(...) {
   shiny::updateTabsetPanel(...)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions