Closed KZARCA closed 7 years ago
I have a similar problem. My dropdownMenu:
output$messageMenu <- renderMenu({ dropdownMenu(....)})
contains reactive values, and tabs will jump back to the first tab when values are changed.
isolate
stopped this problem so its probably due to reactive
?
I apologize for not being very responsive lately. This is a bit surprising (especially becausebarbara/renderMenu
is behind master right now). However, I'm not currently working on this project, so unfortunately, the best answer I can give right now is to use a workaround to ensure that you stay on the current tab. See my answer to #232 for more details. I'd recommend using this workaround until I can understand the root of this issue (which I'll leave open until I start working on this package again).
Psych! Sorry, forget my last comment... I actually ended up spending some time on this now because it was so surprising at first. Luckily, the fix was surprisingly simple (see PR for details). You should all be able to run you original workaround-less code now if you install shinydashboard
from master. Let me know if there's anything not working right.
Thank you very much, it seems to work like a charm!
Thank you, I updated the recent version. Just for info, the version number is not updated in the DESCRIPTION file (don't know whether that matters at all). Thanks anyways!
It doesn't really matter, but it should always be up to date to differentiate between the current development version (master
here in Github) and the current released version (on CRAN). I've just updated it now. Thanks for the catch.
Hi, I notice a similar behaviour with the following code when I click on the actionButton. It seems to be due to Shiny.(un)bindAll:
library(shiny)
library(shinydashboard)
library(shinyjs)
jscode <- 'shinyjs.writeABC = function(){
Shiny.unbindAll();
$("#foo").val("abc");
Shiny.bindAll();
}
'
ui <- dashboardPage(
dashboardHeader(
title = NULL
),
dashboardSidebar(
sidebarMenuOutput("menuUI"),
textInput("foo", "Type something", "")
),
dashboardBody(
useShinyjs(),
extendShinyjs(text = jscode),
tabItems(
tabItem(tabName = "tab1",
h1("tab1")
),
tabItem(tabName = "tab2",
h1("tab2"),
actionButton("click", "Write ABC")
)
)
)
)
server <- shinyServer(function(input, output, session) {
output$menuUI <- renderMenu({
sidebarMenu(
menuItem("Tab1", tabName = "tab1"),
menuItem("Tab2", tabName = "tab2")
)
})
observeEvent(input$click, {
js$writeABC()
})
})
shinyApp(ui, server)
How can I install shinydashboard package from master?
Hi, There is an issue resolved in the
barbara/renderMenu
branch, but still occurring in the master branch: when the selected tab is not the first, and the renderMenu is invalidated, the first tab gets selected. Here is an example:If you type something inside the textInput, tab1 is selected.