Skip to content

Fix About nav accordion always starting expanded#2434

Merged
clouvet merged 1 commit into
mainfrom
fix/about-accordion-always-open
Jul 21, 2026
Merged

Fix About nav accordion always starting expanded#2434
clouvet merged 1 commit into
mainfrom
fix/about-accordion-always-open

Conversation

@clouvet

@clouvet clouvet commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem

On every docs page (e.g. https://fly.io/docs), the left-nav About accordion starts expanded. It should only auto-expand when you're actually on an /docs/about/... page.

Root cause

#2431 added a nav entry with no :path to the About list:

{ text: "Cookie preferences", cookie_prefs: true }

In partials/_accordion_nav.html.erb, section_open? decides whether an accordion starts open. Its link-scan clause called current_page?(page[:path]) without a nil guard:

(section[:links] && section[:links].any? { |page| current_page?(page[:path]) || ... })

For the Cookie preferences entry page[:path] is nil, and Padrino's current_page? treats a nil/blank argument as matching the current request — so About evaluated as "open" on every page.

The method's first clause already guards this exact case for section[:path] (!section[:path].nil? && current_page?(...)); the .any? clause simply lacked the same guard.

Fix

Add the matching nil guard so pathless entries no longer count as the current page:

(section[:links] && section[:links].any? { |page| (!page[:path].nil? && current_page?(page[:path])) || (page[:links] && section_open?(page)) })

About still auto-expands when you're on a real /docs/about/... page; it just no longer forces itself open everywhere. Also protects any future pathless nav entries.

🤖 Generated with Claude Code

The section_open? helper's link-scan clause called current_page?(page[:path])
without guarding against a nil path. PR #2431 added a pathless nav entry
({ text: "Cookie preferences", cookie_prefs: true }) to the About section, and
Padrino's current_page? treats a nil/blank argument as matching the current
request — so About registered as open on every page.

Add the same nil guard the section[:path] clause already uses, so pathless
entries no longer count as the current page. About still auto-expands when
you're actually on a /docs/about/... page.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@clouvet
clouvet merged commit 4b6afc6 into main Jul 21, 2026
2 checks passed
@clouvet
clouvet deleted the fix/about-accordion-always-open branch July 21, 2026 15:21
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.

1 participant