alphagov / alphagov/tech-docs-gem

Bug: Link in navigation point to the right ID when a heading is shared between two pages

Open
#310 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
16
Forks
47
Avg merge
1d 21h
Merged PRs (30d)
14

Description

What should change

The computation of unique IDs for the links in the navigation gives the wrong results when:

  • two pages share a common heading
  • you're on one of these two pages
  • the navigation has a link to the other page pointing to the shared heading

The link points to an ID composed of the heading and the previous heading (for ex. /javascript-api-reference/#javascript-api-reference-button), as if the target was on the current page. It should instead be only the heading (in the example /javascript-api-reference/#button) as on the other page, the ID is unique.

To reproduce:

  • checkout this commit of govuk-frontend-docs (dd1d088), - npm install,
  • bundle install
  • bundle exec middleman server
  • Navigate to "Sass API Reference"
  • Expand the menu item for "JavaScript API Reference"
  • The "Button" link will point to #javascript-api-reference-button, while when browsing the other pages, it points to #button

User need

When publishing the latest release of the design system, we had our JavaScript API Reference and Sass API Reference both list the Button component, leading to the issue described. A situation that may happen further as both docs get expanded and list the options for our components. Other documentations with repetitive structure/content across pages may run into this issue as well.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue from commit dd1d088 using npm install, bundle install, and bundle exec middleman server. Trace how navigation links compute heading IDs when browsing from Sass API Reference to JavaScript API Reference, then verify that the shared Button link resolves to #button rather than the current-page-prefixed ID.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.