Skip to content

Commit 746cb0d

Browse files
authored
Move navbar search after nav links so tab order matches visual order (#14754)
In a collapsible navbar, the search control came right after the brand in the DOM, while CSS flex `order` places it at the far right. Keyboard and screen-reader users reached search before the navigation links. The navsearch partial now comes at the end of the collapse branch in nav-before-body.ejs, after the nav links and tools, so tab order runs brand, nav links, tools, search (WCAG technique C27). The rendered layout does not change: every navbar child has its own CSS `order` at each breakpoint, and search stays outside the collapse region. Custom CSS or JS that expects `#quarto-search` to come before the nav links in the DOM, such as sibling selectors, needs updating. - Add a smoke-all test checking that search follows the collapse region and the tools in the navbar. Fixes #7058
1 parent 183154f commit 746cb0d

5 files changed

Lines changed: 43 additions & 3 deletions

File tree

‎news/changelog-1.11.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ All changes included in 1.11:
1212
## Accessibility
1313

1414
- ([#730](https://github.com/quarto-dev/quarto-cli/issues/730)): Fix keyboard navigation of tabsets in HTML documents without Bootstrap (`theme: none`): Tab now moves from the selected tab into its panel instead of selecting the next tab, and the arrow keys switch tabs.
15+
- ([#7058](https://github.com/quarto-dev/quarto-cli/issues/7058)): Move the navbar search control after the navigation links and tools in the DOM so keyboard and screen-reader order matches the visual order. The rendered layout is unchanged (navbar positioning is controlled by CSS `order`), but custom CSS or JS that relied on `#quarto-search` preceding the navbar links in the DOM may need updating.
1516
- ([#13463](https://github.com/quarto-dev/quarto-cli/issues/13463)): The dark/light mode toggle is now a switch (`button` with `role="switch"`, `aria-checked`, and a localized `aria-label`) instead of a link.
1617
- ([#14615](https://github.com/quarto-dev/quarto-cli/issues/14615)): Fix invalid `role="menu"` on the website navbar's collapse toggle button, flagged by axe-core (`aria-allowed-role`) and WAVE (`aria-role-mismatch`).
1718
- ([#12116](https://github.com/quarto-dev/quarto-cli/issues/12116), [#4935](https://github.com/quarto-dev/quarto-cli/issues/4935)): Website sidebar section toggles are now `<button>` elements, so they are keyboard accessible and properly announced.

‎src/resources/projects/website/templates/nav-before-body.ejs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ const navbarTocRight = nav['toc-location'] === "right" || nav['toc-location'] ==
2626
}) %>
2727
<% if (nav.navbar.left || nav.navbar.right) { %>
2828
<% if (nav.navbar.collapse) { %>
29-
<% if (nav.navbar.search) { %>
30-
<% partial('navsearch.ejs', { classes: '', language: nav.language }) %>
31-
<% } %>
3229
<% partial('navtoggle.ejs', { language: nav.language }) %>
3330
<% partial('navcollapse.ejs') %>
3431
<% partial('navitems.ejs', { align: 'start', items: nav.navbar.left, draftMode: nav.draftMode}) %>
@@ -40,6 +37,9 @@ const navbarTocRight = nav['toc-location'] === "right" || nav['toc-location'] ==
4037
<% if (!nav.navbar["tools-collapse"]) { %>
4138
<% partial('navtools.ejs', { align: 'none', tools: nav.navbar.tools, darkToggle: nav.navbar.darkToggle, readerToggle: nav.navbar.readerToggle, search: false, className: navbarToolsClass, language: nav.language }) %>
4239
<% } %>
40+
<% if (nav.navbar.search) { %>
41+
<% partial('navsearch.ejs', { classes: '', language: nav.language }) %>
42+
<% } %>
4343
<% } else { %>
4444
<% partial('navitems.ejs', { align: 'start', items: nav.navbar.left, draftMode: nav.draftMode}) %>
4545
<% partial('navitems.ejs', { align: 'end', items: nav.navbar.right, draftMode: nav.draftMode }) %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.quarto/
2+
*.html
3+
search.json
4+
site_libs/
5+
**/*.quarto_ipynb
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
project:
2+
type: website
3+
output-dir: .
4+
5+
website:
6+
title: "Website"
7+
search: true
8+
navbar:
9+
left:
10+
- href: index.qmd
11+
text: Home
12+
tools:
13+
- icon: github
14+
href: https://github.com/quarto-dev/quarto-cli
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: "Website"
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
-
8+
# search comes after the collapse (nav links) and the tools
9+
- '#navbarCollapse ~ #quarto-search'
10+
- '.quarto-navbar-tools ~ #quarto-search'
11+
-
12+
# search must not precede the nav links or the toggler
13+
- '#quarto-search ~ #navbarCollapse'
14+
- '#quarto-search ~ .navbar-toggler'
15+
---
16+
17+
Regression test for issue 7058: in the navbar, the search div must come last
18+
in the DOM — after the toggler, the collapsible nav links, and the tools — so
19+
that keyboard/screen-reader order matches the visual order (the CSS `order`
20+
properties place search rightmost at every breakpoint; WCAG technique C27).

0 commit comments

Comments
 (0)