Skip to content

Commit 70e3269

Browse files
authored
fix(ui5-date-picker): input type is now conveyed (#2628)
The component input type is recognised by the screen reader, with the help of 'aria-roledescription' attribute. Fixes #2604
1 parent af64f35 commit 70e3269

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

packages/main/src/DatePicker.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { isPhone, isIE } from "@ui5/webcomponents-base/dist/Device.js";
1919
import "@ui5/webcomponents-icons/dist/appointment-2.js";
2020
import "@ui5/webcomponents-icons/dist/decline.js";
21-
import { DATEPICKER_OPEN_ICON_TITLE, DATEPICKER_DATE_ACC_TEXT, INPUT_SUGGESTIONS_TITLE } from "./generated/i18n/i18n-defaults.js";
21+
import { DATEPICKER_OPEN_ICON_TITLE, DATEPICKER_DATE_DESCRIPTION, INPUT_SUGGESTIONS_TITLE } from "./generated/i18n/i18n-defaults.js";
2222
import DateComponentBase from "./DateComponentBase.js";
2323
import Icon from "./Icon.js";
2424
import Button from "./Button.js";
@@ -590,13 +590,13 @@ class DatePicker extends DateComponentBase {
590590

591591
get accInfo() {
592592
return {
593-
"ariaDescribedBy": `${this._id}-date`,
593+
"ariaRoledescription": this.dateAriaDescription,
594594
"ariaHasPopup": "true",
595595
"ariaAutoComplete": "none",
596596
"role": "combobox",
597597
"ariaOwns": `${this._id}-responsive-popover`,
598598
"ariaExpanded": this.isOpen(),
599-
"ariaDescription": this.dateAriaDescription,
599+
"ariaRequired": this.required,
600600
"ariaLabel": getEffectiveAriaLabelText(this),
601601
};
602602
}
@@ -610,7 +610,7 @@ class DatePicker extends DateComponentBase {
610610
}
611611

612612
get dateAriaDescription() {
613-
return this.i18nBundle.getText(DATEPICKER_DATE_ACC_TEXT);
613+
return this.i18nBundle.getText(DATEPICKER_DATE_DESCRIPTION);
614614
}
615615

616616
/**

packages/main/src/Input.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
?aria-invalid="{{accInfo.input.ariaInvalid}}"
2222
aria-haspopup="{{accInfo.input.ariaHasPopup}}"
2323
aria-describedby="{{accInfo.input.ariaDescribedBy}}"
24+
aria-roledescription="{{accInfo.input.ariaRoledescription}}"
2425
aria-autocomplete="{{accInfo.input.ariaAutoComplete}}"
2526
aria-expanded="{{accInfo.input.ariaExpanded}}"
2627
aria-label="{{accInfo.input.ariaLabel}}"

packages/main/src/Input.js

+1
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@ class Input extends UI5Element {
10591059

10601060
return {
10611061
"input": {
1062+
"ariaRoledescription": this._inputAccInfo && (this._inputAccInfo.ariaRoledescription || undefined),
10621063
"ariaDescribedBy": ariaDescribedBy || undefined,
10631064
"ariaInvalid": this.valueState === ValueState.Error ? "true" : undefined,
10641065
"ariaHasPopup": this._inputAccInfo.ariaHasPopup ? this._inputAccInfo.ariaHasPopup : ariaHasPopupDefault,

packages/main/src/i18n/messagebundle.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ BUTTON_ARIA_TYPE_REJECT=Negative Action
3131
#XACT: ARIA announcement for the emphasized button
3232
BUTTON_ARIA_TYPE_EMPHASIZED=Emphasized
3333

34-
#XACT: Date
35-
DATEPICKER_DATE_ACC_TEXT=Date
36-
3734
# Carousel of text
3835
CAROUSEL_OF_TEXT=of
3936

@@ -49,6 +46,9 @@ CAROUSEL_NEXT_ARROW_TEXT=Next Page
4946
#XACT: DatePicker 'Open Picker' icon title
5047
DATEPICKER_OPEN_ICON_TITLE=Open Picker
5148

49+
#XACT: Aria information for the Date Picker
50+
DATEPICKER_DATE_DESCRIPTION=Date Input
51+
5252
DELETE=Delete
5353

5454
FILEUPLOAD_BROWSE=Browse...

packages/main/test/specs/DatePicker.spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ describe("Date Picker Tests", () => {
88

99
it("input renders", () => {
1010
datepicker.id = "#dp";
11+
1112
assert.ok(datepicker.input.isDisplayedInViewport(), "input is rendered");
1213
assert.ok(datepicker.innerInput.isDisplayedInViewport(), "inner input is rendered");
14+
assert.strictEqual(datepicker.innerInput.getAttribute("aria-roledescription"), "Date Input", "aria-roledescription attribute is added.");
1315
});
1416

1517
it("input receives value", () => {

0 commit comments

Comments
 (0)