Skip to content

fix: sidebar parent link does nothing on product sub-pages#144

Open
pmigueld wants to merge 3 commits into
v2-odoo19-doc-refreshfrom
fix/sidebar-parent-link-nav
Open

fix: sidebar parent link does nothing on product sub-pages#144
pmigueld wants to merge 3 commits into
v2-odoo19-doc-refreshfrom
fix/sidebar-parent-link-nav

Conversation

@pmigueld

Copy link
Copy Markdown

Problem

On the live docs (v2.0): expand Products → click a product (e.g. SP-MIS) → click a sub-page (e.g. Modules included) → click the product name again. Expected: return to the product index. Actual: nothing happens, you stay on the sub-page.

Root cause

Not the theme. The clean-URL post-processing hook update_html_files in docs/conf.py strips a trailing index.html from internal links:

if href.endswith('index.html'):
    a_tag['href'] = href[:-10]

sphinx-build emits the parent link as href="index.html" (same directory). "index.html"[:-10] == "", and an empty href resolves to the current page — so the link does nothing. Sibling/ancestor links keep a path prefix (../social_registry/index.html../social_registry/) and are unaffected.

The hook is gated by SPHINX_DEV_BUILD, so it runs only on the production/deploy build — which is why the bug appears on the live site but not in make livehtml.

Fix

Fall back to ./ when stripping would leave an empty href:

a_tag['href'] = href[:-len('index.html')] or './'

./ resolves to the directory index, fixing every section (not just products).

Verification

Reproduced the production build locally (full build without SPHINX_DEV_BUILD so the hook runs):

  • Before: parent link rendered href=""; click did nothing.
  • After: parent link renders href="./". Served the build and drove headless Chrome — clicking OpenSPP SP-MIS on /products/spmis/modules_included.html navigates to /products/spmis/. Confirmed.

🤖 Generated with Claude Code

The clean-URL post-processing in `update_html_files` stripped the trailing
`index.html` from internal links via `href[:-10]`. For a bare same-directory
link (`href="index.html"`) this produced an empty string, which the browser
resolves to the current page. As a result, clicking a section's parent entry
in the sidebar (e.g. a product name, from one of its sub-pages) did nothing
instead of returning to the section index.

Fall back to "./" when stripping would leave an empty href, so the link still
points at the directory index. This only runs on the production build
(gated by SPHINX_DEV_BUILD), which is why it surfaced on the live site.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the HTML post-processing logic in docs/conf.py to ensure that internal links ending with 'index.html' collapse to './' instead of an empty string, preventing broken self-referencing links. The reviewer identified a critical issue where this logic could incorrectly match and mangle other files ending in 'index.html' (such as 'genindex.html'), leading to 404 errors, and provided a code suggestion to safely restrict the matching criteria.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread docs/conf.py Outdated
pmigueld and others added 2 commits June 11, 2026 16:09
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

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