Skip to content

Changelog version outline links use relative hash, break on non-root pages #387

@gakonst

Description

@gakonst

Bug Description

When using the :::changelog directive on a non-root page (e.g., /changelog), clicking on version links in the Versions outline redirects to /#v1.0.0-rc.5 instead of /changelog#v1.0.0-rc.5.

Steps to Reproduce

  1. Create a changelog page at /changelog with the :::changelog directive
  2. Click on any version in the "Versions" outline on the right side
  3. Observe that it navigates to /#version instead of /changelog#version

Expected Behavior

Version links should navigate to /changelog#v1.0.0-rc.5 (keeping the current page path).

Actual Behavior

Version links navigate to /#v1.0.0-rc.5 (losing the page path, just hash on root).

Root Cause

In src/react/internal/Changelog.client.tsx, line ~203:

<a
  href={`#${release.version}`}

This relative hash link does not preserve the current pathname on some browsers/routers.

Suggested Fix

Use the current pathname when building the href:

const pathname = useLocation().pathname
// ...
<a
  href={`${pathname}#${release.version}`}

Or use React Router's Link component with to={{ hash: release.version }}.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions