fix(close-button): add a default slot containing visually hidden text for close button #5881
+53
−3
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.
fix(close-button): add accessible name support for default slot
Description
Added visually hidden default slot rendering to
sp-close-buttonso text content is accessible to screen readers while remaining invisible to sighted users.Changes:
.visually-hiddenstyling inCloseButton.ts.visually-hiddenCSS class toclose-button-overrides.cssMotivation 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 thelabelattribute.The
labelattribute already worked correctly (viaaria-label), but the documented default slot pattern was inaccessible.Related issue(s)
SWC-1150Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Verify accessible name with default slot
<sp-close-button>Close</sp-close-button>examplesVerify disabled state accessibility
<sp-close-button disabled>Disabled</sp-close-button>Verify label attribute still works
<sp-close-button label="Close"></sp-close-button>Device review