Repository navigation
Conversation
Wrap the top navigation bar in a <header> element so the page has a banner landmark, and render the content area as <main> when no sidebar is present (sidebar pages already get one via page_main_container()). Both changes are made in page_navbar() rather than the shared navs_bar_() so that embedded navset_bar() instances don't produce inappropriate page-level landmarks. The <main> change is done in-place (the content div's tag is renamed) to preserve fill layout behavior.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Thanks for picking this up! Adding banner and main landmarks to page_navbar() is a real accessibility improvement, and keeping the change out of navset_bar() is the right call.
The blocking issue is that bslib's CSS for navbars assumes the .navbar and its content container are adjacent siblings, which is the shape navbarPage_() produces for page_navbar(), shiny::navbarPage(), and navset_bar() alike. Wrapping the nav in <header> and renaming the content div to <main> changes that shape for page_navbar() only, which causes visible layout regressions in existing apps (details inline). I tested an alternative that adds the same landmarks by renaming the existing elements instead, which keeps the DOM shape and needs no CSS changes.
with @shelbylevel, and Posit Asisstant/Kimi K3
Fixes #1356
Wrap the top navigation bar in a
<header>element so the page has a banner landmark, and render the content area as<main>when no sidebar is present (sidebar pages already get one viapage_main_container()).Both changes are made in
page_navbar()rather than the sharednavs_bar_()so that embeddednavset_bar()instances don't produce inappropriate page-level landmarks. The<main>change is done in-place (the content div's tag is renamed) to preserve fill layout behavior.Pull Request
Before you submit a pull request, please ensure you've completed the following checklist
Ensure there is an already open and relevant GitHub issue describing the problem in detail and you've already received some indication from the maintainers that they are welcome to a contribution to fix the problem. This helps us to prevent wasting anyone's time.
Add unit tests in the tests/testthat directory.
This project uses roxygen2 for documentation. If you've made changes to documentation, run
devtools::document().Run
devtools::check()(or, equivalently, click on Build->Check Package in the RStudio IDE) to make sure your change did not add any messages, warnings, or errors.Ensure your code changes follow the style outlined in http://r-pkgs.had.co.nz/style.html
Add an entry to NEWS.md concisely describing what you changed.