Skip to content

Conversation

@cdransf
Copy link
Member

@cdransf cdransf commented Nov 13, 2025

fix(close-button): add accessible name support for default slot

Description

Added visually hidden default slot rendering to sp-close-button so text content is accessible to screen readers while remaining invisible to sighted users.

Changes:

  • Render default slot with .visually-hidden styling in CloseButton.ts
  • Add .visually-hidden CSS class to close-button-overrides.css
  • Add accessibility tests to verify screen reader support

Motivation and context

<sp-close-button>Close</sp-close-button> had no accessible name for screen readers because the default slot wasn't being rendered. This caused WCAG 4.1.2 (Name, Role, Value - Level A) violations when using slot content instead of the label attribute.

The label attribute already worked correctly (via aria-label), but the documented default slot pattern was inaccessible.

Related issue(s)

  • fixes SWC-1150

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Verify accessible name with default slot

    1. Go to close-button documentation
    2. Enable a screen reader (NVDA, JAWS, VoiceOver, etc.)
    3. Navigate to <sp-close-button>Close</sp-close-button> examples
    4. Expect screen reader announces "Close" as the button's accessible name
  • Verify disabled state accessibility

    1. Navigate to disabled close button: <sp-close-button disabled>Disabled</sp-close-button>
    2. Expect screen reader announces "Disabled" and disabled state
  • Verify label attribute still works

    1. Navigate to <sp-close-button label="Close"></sp-close-button>
    2. Expect screen reader announces "Close" via aria-label (existing behavior)

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

@cdransf cdransf self-assigned this Nov 13, 2025
@cdransf cdransf requested a review from a team as a code owner November 13, 2025 00:19
@cdransf cdransf added the Status: Ready for review PR ready for review or re-review. label Nov 13, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

⚠️ No Changeset found

Latest commit: b13b306

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

📚 Branch Preview

🔍 Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-5881

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@cdransf cdransf force-pushed the cdransf/close-button-name branch from 2b5f3f1 to b13b306 Compare November 13, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Ready for review PR ready for review or re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants