Skip to content

Accessibility: Add informative aria-label to the PremiumBadge domain component #103742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,11 @@ class DomainRegistrationSuggestion extends Component {

if ( isPremium ) {
badges.push(
<PremiumBadge key="premium" restrictedPremium={ premiumDomain?.is_price_limit_exceeded } />
<PremiumBadge
key="premium"
restrictedPremium={ premiumDomain?.is_price_limit_exceeded }
domainName={ this.props.suggestion.domain_name }
/>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,30 @@ class PremiumBadge extends Component {
}

render() {
const { restrictedPremium } = this.props;
const { restrictedPremium, domainName, translate } = this.props;
const { text, description } = this.getPopoverText( restrictedPremium );
const badgeClassNames = clsx( 'premium-badge', {
'restricted-premium': restrictedPremium,
} );

const popoverAriaLabel = restrictedPremium
? translate( '%(domainName)s is a restricted premium domain. Learn more', {
args: { domainName },
comment:
'Accessible label for premium badge when a domain is restricted. %(domainName)s is the domain name',
} )
: translate( '%(domainName)s is a premium domain. Learn more', {
args: { domainName },
comment:
'Accessible label for premium badge when a domain is not restricted. %(domainName)s is the domain name',
} );

return (
<Badge className={ badgeClassNames }>
{ text }
<InfoPopover iconSize={ 16 }>{ description }</InfoPopover>
<InfoPopover iconSize={ 16 } aria-label={ popoverAriaLabel }>
{ description }
</InfoPopover>
</Badge>
);
}
Expand Down
3 changes: 2 additions & 1 deletion client/components/info-popover/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class InfoPopover extends Component {
] ),
showOnHover: PropTypes.bool,
children: PropTypes.node,
'aria-label': PropTypes.string,
};

static defaultProps = {
Expand Down Expand Up @@ -125,7 +126,7 @@ export default class InfoPopover extends Component {
type="button"
aria-haspopup
aria-expanded={ this.state.showPopover }
aria-label={ translate( 'More information' ) }
aria-label={ this.props[ 'aria-label' ] || translate( 'More information' ) }
onClick={ this.handleClick }
onMouseEnter={ this.handleOnMouseEnterButton }
onMouseLeave={ this.handleOnMouseLeave }
Expand Down