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
14 changes: 8 additions & 6 deletions packages/main/cypress/specs/CheckBox.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,13 @@ describe("Accessibility", () => {
const accInfo = checkbox.accessibilityInfo;

// Description should come from accessibleName property
expect(accInfo.description).to.equal("Custom Aria Label");
expect(accInfo.description).to.equal("Custom Aria Label Not checked");

expect(accInfo.readonly).to.be.true;
expect(accInfo.required).to.be.true;
expect(accInfo.disabled).to.be.false;


expect(accInfo.type).to.equal("Checkbox");
expect(accInfo.role).to.equal("checkbox");
});
});
Expand All @@ -432,7 +433,7 @@ describe("Accessibility", () => {
const accInfo = checkbox.accessibilityInfo;

// Description should come from associated label
expect(accInfo.description).to.equal("Label For Accessibility Test");
expect(accInfo.description).to.equal("Label For Accessibility Test Not checked");
});
});

Expand All @@ -441,7 +442,8 @@ describe("Accessibility", () => {
<>
<CheckBox
id="accessibilityTestCb2"
text="Accessibility Test Text"
text="Accessibility Test Text"
checked
></CheckBox>
</>
);
Expand All @@ -451,7 +453,7 @@ describe("Accessibility", () => {
const accInfo = checkbox.accessibilityInfo;

// Description should come from text property
expect(accInfo.description).to.equal("Accessibility Test Text");
expect(accInfo.description).to.equal("Accessibility Test Text Checked");
});
});

Expand All @@ -470,7 +472,7 @@ describe("Accessibility", () => {
const accInfo = checkbox.accessibilityInfo;

// Description should come from associated label
expect(accInfo.description).to.equal("Label For Accessibility Test");
expect(accInfo.description).to.equal("Label For Accessibility Test Not checked");
});
});
});
9 changes: 8 additions & 1 deletion packages/main/src/CheckBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import {
VALUE_STATE_WARNING,
VALUE_STATE_SUCCESS,
FORM_CHECKABLE_REQUIRED,
CHECKBOX_CHECKED,
CHECKBOX_NOT_CHECKED,
CHECKBOX_ARIA_TYPE,
} from "./generated/i18n/i18n-defaults.js";

// Styles
Expand Down Expand Up @@ -466,9 +469,13 @@ class CheckBox extends UI5Element implements IFormInputElement {
}

get accessibilityInfo() {
const checkboxState = this.checked ? CheckBox.i18nBundle.getText(CHECKBOX_CHECKED) : CheckBox.i18nBundle.getText(CHECKBOX_NOT_CHECKED);
const description = `${this.ariaLabelText || this.text || ""} ${checkboxState}`;

return {
role: this.accInfo.role,
description: this.ariaLabelText || this.text || "",
type: CheckBox.i18nBundle.getText(CHECKBOX_ARIA_TYPE),
description,
disabled: !!this.accInfo.ariaDisabled,
readonly: !!this.accInfo.ariaReadonly,
required: this.accInfo.ariaRequired,
Expand Down
9 changes: 9 additions & 0 deletions packages/main/src/i18n/messagebundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,15 @@ DYNAMIC_DATE_RANGE_LAST_YEARS_TEXT=Last X Years
#XFLD: Text for the "Next Years" option in the DynamicDateRange component.
DYNAMIC_DATE_RANGE_NEXT_YEARS_TEXT=Next X Years

#XACT: Text for checkbox state - checked
CHECKBOX_CHECKED=Checked

#XACT: Text for checkbox state - not checked
CHECKBOX_NOT_CHECKED=Not checked

#XACT: ARIA type for checkbox
CHECKBOX_ARIA_TYPE=Checkbox

#XFLD: Label for the value input field in the DynamicDateRange component.
DYNAMIC_DATE_RANGE_VALUE_LABEL_TEXT=Value for X

Expand Down
Loading