Skip to content

Fix: Accessible name mismatch for AI Chat button#3934

Open
huangkevin-apr wants to merge 3 commits intoGitbookIO:mainfrom
huangkevin-apr:fix-a11y-ai-icon
Open

Fix: Accessible name mismatch for AI Chat button#3934
huangkevin-apr wants to merge 3 commits intoGitbookIO:mainfrom
huangkevin-apr:fix-a11y-ai-icon

Conversation

@huangkevin-apr
Copy link

@huangkevin-apr huangkevin-apr commented Jan 23, 2026

Summary

This PR fixes an accessibility violation on website doc page where the accessible name of the AI Chat button did not match its visible label, as reported by the IBM Equal Access Accessibility Checker.

image

The issue occurred because the button’s accessible name was implicitly derived from a non-string label prop (a JSX node), which resulted in an incorrect or opaque accessible name (e.g. [object Object]). This caused screen readers and a11y tools to report a mismatch between the visible label and the accessible name.

Solution

Explicitly set a string-based accessible name using the aria-label prop.

Keep the existing label prop for tooltip / visual rendering only.

<Button
  iconOnly={!showLabel || isMobile}
  size="medium"
  variant="header"
  label={
+ aria-label={t(language, 'ai_chat_ask', assistant.label)} // Explicit accessible name string
    <div className="flex items-center gap-2">
      {t(language, 'ai_chat_ask', assistant.label)}
      {withShortcut ? (

This ensures:

  • The accessible name is always a plain string
  • It matches the visible label text
  • Screen readers and automated checkers can correctly interpret the control

Testing

The patch submitted in this PR was generated by A11YRepair, an automated Web Accessibility repair tool that I developed to address common accessibility violations in web applications. The generated fixes were manually reviewed and validated before submission.

The fix has been manually verified in the following locales:

✅ English
✅ Chinese
✅ French
image
image
image

@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

🦋 Changeset detected

Latest commit: bc80ccb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gitbook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@SamyPesse SamyPesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! please update the branch with main where we made changes to the CI to trigger preview deployments. And also add a changeset by running bun run changeset

iconOnly={!showLabel || isMobile}
size="medium"
variant="header"
aria-label={t(language, 'ai_chat_ask', assistant.label)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to use tString here, otherwise it returns a ReactNode

Copy link
Author

@huangkevin-apr huangkevin-apr Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback, I have updated these details.

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

Successfully merging this pull request may close these issues.

2 participants