Skip to content

DOC-14254 off-by-one error in page-nav-header-levels#200

Merged
osfameron merged 2 commits intomasterfrom
DOC-14254-page-nav-header-levels-error
Apr 24, 2026
Merged

DOC-14254 off-by-one error in page-nav-header-levels#200
osfameron merged 2 commits intomasterfrom
DOC-14254-page-nav-header-levels-error

Conversation

@osfameron
Copy link
Copy Markdown
Contributor

Setting to 1 is intended to keep only the first level open e.g. show the direct children of the first bold level.

Oops... looks like an off-by-one-error... building Staging to test...

Setting to 1 is intended to keep only the first level open
e.g. show the direct children of the first bold level.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the collapsing behavior of the left navigation tree controlled by page-nav-header-levels, intended to keep a certain number of header levels expanded by default.

Changes:

  • Updates the depth comparison used to decide when a nav subtree should be collapsed (> to >=).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/js/01-nav.js Outdated
// originally we would collapse everything, but we can set :page-nav-header-levels: 1 to have
// up to the bold subheadings kept open
if (currentPath.length > page.navHeaderLevels) {
if (currentPath.length >= page.navHeaderLevels) {
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the collapse condition to currentPath.length >= page.navHeaderLevels will close top-level parents when page-nav-header-levels is set to 1 (since currentPath.length is 1 at the top UL). Those top-level items also don’t get an in-toggle (currentPath.length > 1 check) and are excluded from the click-to-toggle handler (dataset.depth < page.navHeaderLevels), so they become permanently closed unless they contain the current page. Consider reverting to > or rewriting this logic in terms of the same depth metric used elsewhere (e.g., navItemEl.dataset.depth) so page-nav-header-levels: 1 keeps the first level open as intended.

Suggested change
if (currentPath.length >= page.navHeaderLevels) {
if (currentPath.length > page.navHeaderLevels) {

Copilot uses AI. Check for mistakes.
The logic switched based on the number of nav files available.
This broke components where the landing page (defined in docs-site, with a single nav)
referred to a component such as SDK which has multiple navs for different components.

Capella used to have a single one, but has evolved to have multiples in left nav,
causing some oddities.

This change will require setting the correct `:page-nav-header-levels: 1` to
all repos in SDK, as well as the landing pages in docs-site (cloud.adoc,
sdk.adoc, analytics-sdk.adoc, and developer.adoc)
@osfameron osfameron merged commit 7390e27 into master Apr 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants