-
Notifications
You must be signed in to change notification settings - Fork 58
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
bslib::nav_insert()
with repeated inputs fails with error console changes in shiny 1.10.0
#1159
Comments
The duplicated input ID is definitely the source of the problem. We made a small change in shiny 1.10.0 that should better surface warnings about duplicated or shared input/output IDs. In general, I'd urge you not to repeat input or output IDs in your apps. Your solution of using In terms of the markup, I'd recommend the following: nav_item(
tags$a(
class = "nav-link",
href = "#",
onclick = "Shiny.setInputValue('refresh', Date.now() , {priority: 'event'})",
bsicons::bs_icon(
"arrow-clockwise",
size = "1rem",
title = "Refresh data"
)
)
) Two important changes:
Sorry about that! The change was intended to bring clarity to some otherwise obscure issues, but I think something unusual is happening with |
shiny 1.10.0
bslib::nav_insert()
with repeated inputs fails with error console changes in shiny 1.10.0
Here's a much smaller reprex: library(shiny)
library(bslib)
ui <- bslib::page_navbar(
title = "Reprex",
id = "main",
lang = "en"
)
action_link <- shiny::actionLink("refresh", "Refresh", class = "nav-link")
server <- function(input, output, session) {
bslib::nav_insert(
id = "main",
nav = bslib::nav_menu(
title = "Page",
bslib::nav_panel(title = "A", "Page A", action_link),
bslib::nav_panel(title = "B", "Page B", action_link),
# Additional nav panels after duplicate ID warning:
# >> scope.get is not a function
bslib::nav_panel(title = "D", "Page D")
)
)
# This insert works okay
# bslib::nav_insert(
# id = "main",
# nav = bslib::nav_panel(title = "D", "Page D")
# )
}
shiny::shinyApp(ui, server) It appears that you need to:
|
Describe the problem
I have a
nav_menu()
that I populate once certain actions have been taken in an app usingnav_insert()
. The repeatedshiny::actionLink("refresh")
fetches data for that page based oninput$main
. After updating fromshiny 1.9.1
, toshiny 1.10.0
, this app no longer functions.app.R
As of 1.10.0:
The first 2
nav_panels
(A, B) are populated but clicking on (C, D) does nothing whatsoever. Inspecting the javascript console, there are 2 new errors:This is resolved if the action links are replaced with:
Updated
server.R
:nav_menu()
is not rendered in the server (just putting it in the UI).nav_menu()
(nav_insert(id = "main", bslib::nav_panel(title = "A", ...)
.As such, this seems like an incredibly niche issue, but did take a good long while to figure out the fix without any helpful errors, etc.
Session Info
The text was updated successfully, but these errors were encountered: