Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status labels in docs headings break section links #5393

Open
jmuzina opened this issue Oct 21, 2024 · 3 comments
Open

Status labels in docs headings break section links #5393

jmuzina opened this issue Oct 21, 2024 · 3 comments
Labels
Bug 🐛 P3 Triaged Issue has been reviewed as part of legacy backlog grooming (project P3). Triaged: v4 Triaged, to be implemented as part of Vanilla v4

Comments

@jmuzina
Copy link
Member

jmuzina commented Oct 21, 2024

Describe the bug

Our new system for adding status labels in docs pages causes links to docs sections to break. It seems like the status label's text is included in the search for a matching page section, causing navigation to those sections to break.

Consider this heading:

### Dense help text {{ status('updated') }}

This should allow you to navigate to that heading with #dense-help-text. However, you can only navigate to the requested heading by removing the status label.

To Reproduce

Steps to reproduce the behavior:

  1. Checkout the repo
  2. Find any docs heading that has a {{ status() }} label.
  3. Attempt to navigate to it directly by appending the url encoding of the heading to your URL. I.E colour-coding for a "Colour coding" section.
  4. See that the requested heading is not scrolled to on page load. You should also see an error in console:
Uncaught TypeError: title is null
    fixScroll http://0.0.0.0:8101/static/js/example.js?v=0134365:485
    resizeInterval http://0.0.0.0:8101/static/js/example.js?v=0134365:369
    setInterval handler*renderIframe http://0.0.0.0:8101/static/js/example.js?v=0134365:365
    renderExample http://0.0.0.0:8101/static/js/example.js?v=0134365:291
    async* http://0.0.0.0:8101/static/js/example.js?v=0134365:81
    <anonymous> http://0.0.0.0:8101/static/js/example.js?v=0134365:80
    EventListener.handleEvent* http://0.0.0.0:8101/static/js/example.js?v=0134365:77
    <anonymous> http://0.0.0.0:8101/static/js/example.js?v=0134365:512
example.js:485:7
  1. Remove the status label from the markdown title. Retry navigating to the section.
  2. See that the page scrolls to the requested section on load.

Expected behavior

Navigating to a documentation section by using a section name in a hash causes the browser to scroll to that section on load, regardless of status label.

Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/WD-16070.

This message was autogenerated

@bartaz
Copy link
Member

bartaz commented Oct 22, 2024

Hmm… it has been addressed in the original PR that introduced these labels.
I wonder if this doesn't work at all, or are there some specific use cases.

That's the part that was updated:

document.querySelectorAll('main h2:not([id])').forEach(function (heading) {
// Only get direct text from h2 node, excluding any child nodes
var id = heading.childNodes[0].textContent
.trim()
.toLowerCase()
.replaceAll(/\s+/g, '-')
.replaceAll(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '');
heading.setAttribute('id', id);
});

@bartaz bartaz added P3 Triaged Issue has been reviewed as part of legacy backlog grooming (project P3). Triaged: v4 Triaged, to be implemented as part of Vanilla v4 labels Oct 22, 2024
@bartaz
Copy link
Member

bartaz commented Oct 23, 2024

It seems that the JS doesn't even trigger, because anchor ids are generated from Markdown (and label text is taken into account).

For the time being we could use <h2>Heading {{ status_label("New") }}</h2> notation instead, as a workaround.

Another option would be to simply accept the -new (and other) suffixes in URLs and update them when labels are removed from headings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 P3 Triaged Issue has been reviewed as part of legacy backlog grooming (project P3). Triaged: v4 Triaged, to be implemented as part of Vanilla v4
Projects
None yet
Development

No branches or pull requests

2 participants