Repository navigation
fix(theme): provide accessible aria-label on navbar title when siteTitle is false - #5587
Open
abdul-karim-mia wants to merge 1 commit into
Open
abdul-karim-mia wants to merge 1 commit into
abdul-karim-mia wants to merge 1 commit into
Conversation
…tle is false Signed-off-by: Abdul karim mia <akmia51@gmail.com>
👷 Deploy request for vitepress-docs pending review.Visit the deploys page to approve it
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When
themeConfig.siteTitleis configured asfalse, the navbar title text is hidden. IfthemeConfig.logois defined as a string (e.g.logo: '/my-logo.svg') or without analtattribute,<VPImage>renders<img alt="" />and neither<span>renders inside<a class="title">. Consequently, the navigation link to the site home page has no discernible accessible name for screen readers and accessibility audits.This PR provides a fallback
aria-label="site.title"on<a class="title">when:theme.siteTitle === false, andtheme.logodoes not already provide analtattribute (so we don't override explicit alt text).In all other cases (default or custom visible site title, or logo with alt text),
aria-labelremainsundefined.Linked Issues
Addresses #5056
Additional Context
__tests__/unit/client/theme-default/components/VPNavBarTitle.test.tscovering:aria-labelaria-labelsiteTitle: falsewith string logo:aria-label="<site.title>"siteTitle: falsewith logo alt: noaria-label