-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[docs-infra] Fix broken anchor button when header has a link #43598
[docs-infra] Fix broken anchor button when header has a link #43598
Conversation
Netlify deploy previewhttps://deploy-preview-43598--material-ui.netlify.app/ Bundle size report |
headingHtml.includes('<a ') | ||
? [ | ||
// Avoid breaking the anchor link button | ||
`<h${level} id="${hash}"><a href="#${hash}" class="title-link-to-anchor">${headingHtml}</a>`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test this modification on MUI X?
This might work, but still create weird HTML with nested <a/>
elements
If the title contains a link the code
<a>${headingHtml}</a><a><span><svg>...</svg></span></a>
will return
<a>
Main title
<a>Pro component</a>
</a>
<a>
<span><svg>...</svg></span>
</a>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, technically, the nested <a>
tag is not valid and browsers try to "fix" it, which causes the issue this PR aims to fix.
This PR doesn't fix the nested <a>
tag problem but ensures the anchor button works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding testing, I used this page to verify it works: https://deploy-preview-43598--material-ui.netlify.app/experiments/docs/headers/
In MUI X, we often have links in the header marking the Plan.
It turns out, the anchor button doesn't work if the header contains a link – see https://deploy-preview-14443--material-ui-x.netlify.app/x/react-data-grid/#commercial-licenses
This PR fixes the issue.