Description
According to this line, the function updateTabItems
is exactly the same function as shiny::updateTabsetPanel
.
Line 83 in 7ccaacc
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.
-
Create a project in RStudio or Workbench with
renv
enabled. Set therenv
settinguse.cache
tofalse
. -
Restart R.
-
Install
devtools
install.packages("devtools", repos = "cran.rstudio.com")
-
Restart R.
-
Install
shiny
1.5.0
devtools::install_version("shiny", "1.5.0", repos = "cran.rstudio.com")
-
Restart R.
-
Verify
shiny::updateTabsetPanel
does not have the default set forsession
in the function definition. -
Install
shinydashboard
0.7.1
. Don’t upgrade any other packages when prompted.
devtools::install_version("shinydashboard", "0.7.1", repos = "cran.rstudio.com")
-
Restart R.
-
Verify
shinydashboard::updateTabItems
does not have the default set forsession
in the function definition. -
Restart R.
-
Install
shiny
1.6.0
devtools::install_version("shiny", "1.6.0", repos = "cran.rstudio.com")
-
Restart R.
-
Verify
shiny::updateTabsetPanel
does have the default set forsession
in the function definition. -
Verify
shinydashboard::updateTabItems
still does not have the default set forsession
in the function definition. -
Restart R.
-
Reinstall
shinydashboard
0.7.1
. Don’t upgrade any other packages when prompted.
devtools::install_version("shinydashboard", "0.7.1", repos = "cran.rstudio.com")
-
Restart R.
-
Verify
shinydashboard::updateTabItems
now does have the default set forsession
in the function definition.
Perhaps a better way to implement the function would be as follows:
updateTabItems <- function(...) {
shiny::updateTabsetPanel(...)
}