Open chrisbrownlie opened 1 year ago
Is there an alternative way to achieve what I'm looking for?
Hi @chrisbrownlie and thanks for the posting your question! Can you explain a bit more about what you're looking to achieve with the navsets? I'm happy to help but I'm having a hard time seeing what effect you're wanting.
Thanks for replying. This was an oversimplified example, in an app I'm working on we are using a similiar pattern to have a dropdown in the navbar of a page_navbar()
. The dropdown itself contains a card() with a navset in it. Its dynamically rendered if that makes a difference so at the moment it essentially looks like nav_item(uiOutput("dropdown"))
where the uiOutput contains a dropdown with a card that has a nav within it.
Hope that helps clarify, let me know if you need any more info!
That does help, thanks! Unfortunately, the official answer for now is that using dropdowns with nested navsets in the navbar are not supported. The good news is that we are working on a new interface to popovers that may very well address your use case. Stay tuned for more in that department.
I played around a bit with your example and was able to find something that mostly works using the functions we have now, basically using nav_menu(nav_item(navset_card_pill()))
, or a card nested in a nav_item()
nested in a nav_menu()
. This mostly works on the user-side but the navbar logic doesn't anticipate separately nested navsets and the selected nav_panel()
is not returned back to the server.
Here's the app code with a short screen recording of how it works.
https://github.com/rstudio/bslib/assets/5420529/a2f1c50d-012f-457f-9c10-0a3a4cbe6db6
Thanks @gadenbuie, although I was specifically looking for a solution that returned the selected panel to the server-side so I'll keep an eye out for the new popovers feature and hopefully that will resolve the issue!
Describe the problem
When nesting a
navset_
element inside anav_item
within another nav container, the selected tab of the outer nav container doesn't seem to be accessible from the server using theid
argument.For the reprexes below, I would expect the value of
input$main_nav
that is printed to the console to reflect the selected tab, but it seems to be NULL and doesn't register any changes. The inner, nested nav is still accessible from the server withinput$inner_nav
however.Removing the
nav_item
that it is wrapped in seems to make it work again, but gives a warningand usually ends up being formatted differently.
Is there an alternative way to achieve what I'm looking for?
Created on 2023-07-05 with reprex v2.0.2
the same behaviour with different navset/page elements:
Created on 2023-07-05 with reprex v2.0.2
Session Info