Skip to content

Commit

Permalink
fix(a11y): fix PR SonnarQube issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ulates-sap committed Oct 10, 2024
1 parent 3af58bc commit e3d77e3
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ export class CheckoutDeliveryAddressComponent implements OnInit {
const numbers = getAddressNumbers(address, textPhone, textMobile);
const isSelected: boolean = selected && selected.id === address.id;

const isButtonRole =
this.featureConfigService?.isEnabled(
'a11ySelectLabelWithContextForSelectedAddrOrPayment'
) && !isSelected;
const role = isButtonRole ? 'button' : 'region';
const role = this.getCardRole(isSelected);

return {
role,
Expand Down Expand Up @@ -339,4 +335,12 @@ export class CheckoutDeliveryAddressComponent implements OnInit {
protected shouldUseAddressSavedInCart(): boolean {
return !!this.checkoutConfigService?.shouldUseAddressSavedInCart();
}

private getCardRole(isCardSelected: boolean): 'button' | 'region' {
const isButtonRole =
this.featureConfigService?.isEnabled(
'a11ySelectLabelWithContextForSelectedAddrOrPayment'
) && !isCardSelected;
return isButtonRole ? 'button' : 'region';
}
}

0 comments on commit e3d77e3

Please sign in to comment.