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

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

Open
Mosk915 opened this issue Sep 20, 2023 · 2 comments · May be fixed by #398
Open

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

Mosk915 opened this issue Sep 20, 2023 · 2 comments · May be fixed by #398

Comments

@Mosk915
Copy link

Mosk915 commented Sep 20, 2023

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(...)
}
@Rikagx
Copy link

Rikagx commented Sep 26, 2023

There is from Posit support ticket # 95105 which has more information.

@gadenbuie gadenbuie linked a pull request Oct 3, 2023 that will close this issue
@gadenbuie
Copy link
Member

gadenbuie commented Oct 3, 2023

Thanks! I implemented the suggested fix in #398

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

Successfully merging a pull request may close this issue.

3 participants