Skip to content
Open
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
4 changes: 2 additions & 2 deletions packages/main/cypress/specs/RadioButton.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ describe("RadioButton general interaction", () => {
</>);

cy.get("#rb-acc-name").should('have.prop', "ariaLabelText", RADIOBUTTON_LABEL);
cy.get("#rb-acc-name-text").should('have.prop', "ariaLabelText", `${RADIOBUTTON_LABEL} ${RADIOBUTTON_TEXT}`);
cy.get("#rb-acc-name-text").should('have.prop', "ariaLabelText", RADIOBUTTON_LABEL);
});

it("tests accessibleNameRef", () => {
Expand All @@ -357,7 +357,7 @@ describe("RadioButton general interaction", () => {
<RadioButton id="rb-acc-name-ref-with-text" accessibleNameRef="lbl-rb-acc-name-ref-with-text" text={RADIO_BUTTON_TEXT}></RadioButton>
</>);

cy.get("#rb-acc-name-ref-with-text").should("have.prop", "ariaLabelText", `${LABEL_TEXT} ${RADIO_BUTTON_TEXT}`);
cy.get("#rb-acc-name-ref-with-text").should("have.prop", "ariaLabelText", LABEL_TEXT);
});

it("tests accessibleNameRef when the radio button is wrapped by another custom element", () => {
Expand Down
10 changes: 9 additions & 1 deletion packages/main/src/RadioButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,15 @@ class RadioButton extends UI5Element implements IFormInputElement {
}

get ariaLabelText() {
return [getEffectiveAriaLabelText(this), this.text].filter(Boolean).join(" ");
return getEffectiveAriaLabelText(this) || undefined;
}

get ariaLabelledBy() {
if (!this.ariaLabelText) {
return this.text ? `${this._id}-label` : undefined;
}

return undefined;
}

get effectiveAriaDescribedBy() {
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/RadioButtonTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function RadioButtonTemplate(this: RadioButton) {
aria-disabled={this.effectiveAriaDisabled}
aria-describedby={this.effectiveAriaDescribedBy}
aria-label={this.ariaLabelText}
aria-labelledby={this.ariaLabelledBy}
tabindex={this.effectiveTabIndex}
onClick={this._onclick}
onKeyDown={this._onkeydown}
Expand Down
Loading