-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Various improvements to tab panels #3315
Conversation
R/bootstrap.R
Outdated
# Replace <li class="nav-item"><a class="nav-link"></a></li> | ||
# with <a class="dropdown-item"></a> | ||
navItem <- x$children[[1]] | ||
navItem$attribs$class <- "dropdown-item" | ||
navItem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main unfortunate thing about all of this is that BS4 doesn't support <li><a></a></li>
inside of dropdowns, which apparently they brought back in BS5
https://getbootstrap.com/docs/4.6/components/navs/#tabs-with-dropdowns
https://getbootstrap.com/docs/5.0/components/navs-tabs/#tabs-with-dropdowns
Might be worth asking for a backport into BS4, but I doubt we'll see it
…nto 'empty' nav/tab
…e is precedence in navbarPage() and mention them in the warning
496ac66
to
b5b0ba1
Compare
} | ||
|
||
# TODO: something like this should exist in htmltools | ||
tagHasClass <- function(x, class) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complexity of this code inspired this issue:
rstudio/htmltools#205
Co-authored-by: Winston Chang <[email protected]>
* Follow up to #3315: reduce complexity and 'black-boxed' nature of tab panel logic * asTags(selected = FALSE) is now root() * tagAddRenderHook * Add bslib to remotes * Document (GitHub Actions) * root() was recently changed to allTags() * code review * tagQuery() doesn't necessarily preserve order of attributes * place href attribute before data attributes * add nav-item/nav-link to BS4+ dropdowns * Make sure .nav-item is removed in .dropdown-menu Co-authored-by: cpsievert <[email protected]>
This PR closes numerous issues with
tabsetPanel()
/navlistPanel()
/navbarPage()
. See the respective issue links for examples:!!!
may now be used to splicetabPanel()
s into them (closes tabsetPanel() doesn't work with list of panels #2927)tabsetPanel()
andnavlistPanel()
functions gainheader
/footer
arguments, akin to the already existingheader
/footer
arguments innavbarPage()
, making it easier to include content that should appear on every tab (closes Make it easier to include header/footer content in tabsetPanel()/navlistPanel() #3322).NULL
values are now dropped instead of producing an empty nav item (closes tabsetPanel doesn't ignore NULLs #1928).tabPanel()
/shiny.tag
objects are supplied to...
(closes tabsetPanel() et al give confusing error messages when they receive incorrect input #3313, closes tabSetpanel first argument #1823).shiny.tag
object(s) are supplied to...
. In this case we will continue to create an "empty" nav item and include the content on every tab, but the warning will mention the (new)header
/footer
args, which is likely what the user wants (closes Tab panel behavior when shiny tags are supplied #3321).theme = bslib::bs_theme()
(closes Tab panel functions don't produce Bootstrap 4 compatible markup #3320). At least for now, you'll still want{bslibs}
's BS3 compatibility layer to provide sensible styles innavlistPanel()
andnavbarPage()
, but perhaps in follow up PRs we can explore completely removing the compatibility layer dependency for those as well. The main downside to this change in behavior is thattabsetPanel()
now returnstagFunction()
s, meaning that user code which makes assumptions about the return value may break, but hopefully by providing more intelligent tag modification functions (see, for example, Add tagFunction() awareness to tag modifying functions htmltools#202), this won't be much of an issue.Testing notes
Install
remotes::install_github("rstudio/shiny")
then verify there is no regression in the example app above as well as the one below (in the app below, when you click add 'dynamic' tab, a tab should be inserted between Static1 and Static2 in the dropdown)