Open oelhammouchi opened 6 months ago
您好,丁永兵已经收到您的邮件,谢谢。
Hi @OthmanElHammouchi, thanks for your question! It would be helpful if you could rewrite the example so that it includes only the code needed to see and reproduce your issue.
That said, in a quick scan, I noticed this observe:
observeEvent(input$add, {
req(input$add_subitem)
s <- c(subitems(), input$add_subitem)
subitems(s)
updateTabItems(session, "tabs", selected = "setup")
})
What happens here is that the observer updates subitems()
and then calls updateTabItems()
. These are called one after the other in the same observeEvent
block, which means that when updateTabItems()
is called the renderUI()
that creates the menu hasn't been re-rendered yet.
The timeline of events is roughly:
subitems()
subitems()
was updated, losing the currently selected tab.To make this work, you'll need to separate the new tab addition and the tab selection. Hope that helps, and if not please make a smaller reprex (reproducible example) and I'll take another look.
Hi, first of all, thank you so much for your work on this awesome package. I'm using it to build an app at my company, but I'm experiencing the following issue. When
dashboardBody
contains dynamically renderedmenuSubItems
, I cannot manage to select one of them usingupdateTabItems
. Unfortunately I cannot share the code since it's proprietary, but I managed to reproduce the issue by adapting the code from this post:This is the result on initial page load:
Note that the issue goes away completely if I select a top-level tab instead. Any idea what might be causing this and how to remedy it?