Fix About nav accordion always starting expanded#2434
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
:pathto the About list:In
partials/_accordion_nav.html.erb,section_open?decides whether an accordion starts open. Its link-scan clause calledcurrent_page?(page[:path])without a nil guard:For the Cookie preferences entry
page[:path]isnil, and Padrino'scurrent_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:
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