fix(theme-classic): expose empty string alt text in navbar logos#7659
fix(theme-classic): expose empty string alt text in navbar logos#7659Josh-Cena merged 4 commits intofacebook:mainfrom
Conversation
|
Hi @BenDMyers! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
|
@Josh-Cena Do you know of a good place to add unit tests for this sort of thing? |
|
We don't have good unit testing infra for theme components yet, and since this is wired to the theme config, mocking the context is a bit tricky. Since there's already a dogfooding test (which I've always wanted to do anyway), I think that's not very critical. |
| height={logo.height} | ||
| width={logo.width} | ||
| alt={logo.alt || navbarTitle || title} | ||
| alt={logo.alt ?? (navbarTitle || title)} |
There was a problem hiding this comment.
What do you think about the case of alt: undefined and navbar: { title: "TypeScript ESLint" }? Should we use alt="" as well (sounds more sensible to me)?
There was a problem hiding this comment.
I'm pretty much of the mindset that if any text appears in the same link as the logo, the logo should have alt="" - since at that point, the logo serves only to adorn that text.
There was a problem hiding this comment.
Shall we use something closer to the line of logo.alt ?? (navbarTitle ? "" : title) then? (Plus a comment like "respect empty alt, don't show alt that's duplicated from navbar title")
There was a problem hiding this comment.
Sure - I'll pull that out into its own declaration though, so that way it's not all inlined.
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
|
@Josh-Cena That's just how DevTools shows empty |
|
Just pending CLA. I'll go to sleep and @slorber may merge it or I can merge it tomorrow morning (provided the CLA comes through at that time) |
|
I've submitted the CLA on my end - my "receipt": Might need some time to process on y'all's end - not sure how that works |
|
Yes, it can easily take up to hours these days... We can just wait. |
|
No worries! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thanks! LGTM |

Pre-flight checklist
Motivation
Resolves #7658
Allowing users to supply
alt=""(distinct from no alt/undefined alt) for their navbar brand link logos can enable users to reduce clutter in screenreader announcements. However, as it currently stands, when an empty string is provided for a logo alt, Docusaurus falls back to the provided navbar title or the site title.This pull request ensures that if a Docusaurus config provides
alt: ''for a logo, that empty string is respected, so Docusaurus users can confidently mark their logos as decorative and reduce duplicated announcements.Test Plan
Create a fresh Docusaurus site. In the Docusaurus config, update the
navbar.logo.altconfig to be an empty string. Build the site. Verify that the logo element hasalt=""(may show up as simplyaltin some browser devtools).Navigate to the brand link with a screenreader. Verify that the screenreader only announces the site title once (from the visible site title label)
Test links
Choosing to dogfood on the main Docusaurus site's brand logo link:
Deploy preview: https://deploy-preview-7659--docusaurus-2.netlify.app/
Related issues/PRs
Resolves #7658
Prior art in #3352 (which addressed #3350) and #3817 (which addressed #3816)