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

2024-12-17: TOC links to alert headings don't work #4043

Open
AnitaYCheng opened this issue Dec 17, 2024 · 2 comments
Open

2024-12-17: TOC links to alert headings don't work #4043

AnitaYCheng opened this issue Dec 17, 2024 · 2 comments
Assignees

Comments

@AnitaYCheng
Copy link
Contributor

AnitaYCheng commented Dec 17, 2024

Expected behavior

Clicking on a TOC link in the sidebar should take the user to the correct heading.

Current behavior

Headings in alert boxes are populated in the TOC sidebar because they're h3, as expected. But when clicked on, the screen scrolls to the top of the page instead of to the alert heading.

Possible solutions

I suspect this is because on all the other headings, it's the heading tag that has the ID attached to it.
image

But for the alert, it's an empty a tag that has the ID attached to it.
image

I looked at alert.js but wasn't sure how to move that ID assignment. Probably need a real dev on this. 😅

Steps to reproduce (for bugs)

Example with 2 alerts

Context

No response

Your environment

No response

@mgwalker mgwalker self-assigned this Jan 7, 2025
@mgwalker
Copy link
Member

mgwalker commented Jan 7, 2025

This appears to be because the alert shortcode produces HTML so it's not being run through the markdown-it-attrs parser that handles correctly inserting heading links. Though I'm genuinely unsure where the heck the anchor tags are coming from – nowhere in the code seems to be creating them. 🤔

Scratch that. Something in inserting anchor elements into the headings, and doing weird stuff to the scrolling. I suspect USWDS is at play in here.

@mgwalker
Copy link
Member

mgwalker commented Jan 8, 2025

This is a USWDS bug. Tracking in uswds/uswds#6295

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

No branches or pull requests

2 participants