Skip to content

Commit 8edc40e

Browse files
committed
fix(ui5-checkbox): fix accessibilityInfo
1 parent b818abb commit 8edc40e

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

packages/main/cypress/specs/CheckBox.cy.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,13 @@ describe("Accessibility", () => {
406406
const accInfo = checkbox.accessibilityInfo;
407407

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

411411
expect(accInfo.readonly).to.be.true;
412412
expect(accInfo.required).to.be.true;
413413
expect(accInfo.disabled).to.be.false;
414-
414+
415+
expect(accInfo.type).to.equal("Checkbox");
415416
expect(accInfo.role).to.equal("checkbox");
416417
});
417418
});
@@ -432,7 +433,7 @@ describe("Accessibility", () => {
432433
const accInfo = checkbox.accessibilityInfo;
433434

434435
// Description should come from associated label
435-
expect(accInfo.description).to.equal("Label For Accessibility Test");
436+
expect(accInfo.description).to.equal("Label For Accessibility Test Not checked");
436437
});
437438
});
438439

@@ -441,7 +442,8 @@ describe("Accessibility", () => {
441442
<>
442443
<CheckBox
443444
id="accessibilityTestCb2"
444-
text="Accessibility Test Text"
445+
text="Accessibility Test Text"
446+
checked
445447
></CheckBox>
446448
</>
447449
);
@@ -451,7 +453,7 @@ describe("Accessibility", () => {
451453
const accInfo = checkbox.accessibilityInfo;
452454

453455
// Description should come from text property
454-
expect(accInfo.description).to.equal("Accessibility Test Text");
456+
expect(accInfo.description).to.equal("Accessibility Test Text Checked");
455457
});
456458
});
457459

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

472474
// Description should come from associated label
473-
expect(accInfo.description).to.equal("Label For Accessibility Test");
475+
expect(accInfo.description).to.equal("Label For Accessibility Test Not checked");
474476
});
475477
});
476478
});

packages/main/src/CheckBox.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import {
2222
VALUE_STATE_WARNING,
2323
VALUE_STATE_SUCCESS,
2424
FORM_CHECKABLE_REQUIRED,
25+
CHECKBOX_CHECKED,
26+
CHECKBOX_NOT_CHECKED,
27+
CHECKBOX_ARIA_TYPE,
2528
} from "./generated/i18n/i18n-defaults.js";
2629

2730
// Styles
@@ -466,9 +469,13 @@ class CheckBox extends UI5Element implements IFormInputElement {
466469
}
467470

468471
get accessibilityInfo() {
472+
const checkboxState = this.checked ? CheckBox.i18nBundle.getText(CHECKBOX_CHECKED) : CheckBox.i18nBundle.getText(CHECKBOX_NOT_CHECKED);
473+
const description = (this.ariaLabelText || this.text || "") + " " + checkboxState;
474+
469475
return {
470476
role: this.accInfo.role,
471-
description: this.ariaLabelText || this.text || "",
477+
type: CheckBox.i18nBundle.getText(CHECKBOX_ARIA_TYPE),
478+
description,
472479
disabled: !!this.accInfo.ariaDisabled,
473480
readonly: !!this.accInfo.ariaReadonly,
474481
required: this.accInfo.ariaRequired,

packages/main/src/i18n/messagebundle.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,15 @@ DYNAMIC_DATE_RANGE_LAST_YEARS_TEXT=Last X Years
904904
#XFLD: Text for the "Next Years" option in the DynamicDateRange component.
905905
DYNAMIC_DATE_RANGE_NEXT_YEARS_TEXT=Next X Years
906906

907+
#XACT: Text for checkbox state - checked
908+
CHECKBOX_CHECKED=Checked
909+
910+
#XACT: Text for checkbox state - not checked
911+
CHECKBOX_NOT_CHECKED=Not checked
912+
913+
#XACT: ARIA type for checkbox
914+
CHECKBOX_ARIA_TYPE=Checkbox
915+
907916
#XFLD: Label for the value input field in the DynamicDateRange component.
908917
DYNAMIC_DATE_RANGE_VALUE_LABEL_TEXT=Value for X
909918

0 commit comments

Comments
 (0)