Skip to content

Commit

Permalink
fix(ui5-date-picker): input type is now conveyed (#2628)
Browse files Browse the repository at this point in the history
The component input type is recognised by the screen reader,
with the help of 'aria-roledescription' attribute.

Fixes #2604
  • Loading branch information
unazko committed Jan 28, 2021
1 parent af64f35 commit 70e3269
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/main/src/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { isPhone, isIE } from "@ui5/webcomponents-base/dist/Device.js";
import "@ui5/webcomponents-icons/dist/appointment-2.js";
import "@ui5/webcomponents-icons/dist/decline.js";
import { DATEPICKER_OPEN_ICON_TITLE, DATEPICKER_DATE_ACC_TEXT, INPUT_SUGGESTIONS_TITLE } from "./generated/i18n/i18n-defaults.js";
import { DATEPICKER_OPEN_ICON_TITLE, DATEPICKER_DATE_DESCRIPTION, INPUT_SUGGESTIONS_TITLE } from "./generated/i18n/i18n-defaults.js";
import DateComponentBase from "./DateComponentBase.js";
import Icon from "./Icon.js";
import Button from "./Button.js";
Expand Down Expand Up @@ -590,13 +590,13 @@ class DatePicker extends DateComponentBase {

get accInfo() {
return {
"ariaDescribedBy": `${this._id}-date`,
"ariaRoledescription": this.dateAriaDescription,
"ariaHasPopup": "true",
"ariaAutoComplete": "none",
"role": "combobox",
"ariaOwns": `${this._id}-responsive-popover`,
"ariaExpanded": this.isOpen(),
"ariaDescription": this.dateAriaDescription,
"ariaRequired": this.required,
"ariaLabel": getEffectiveAriaLabelText(this),
};
}
Expand All @@ -610,7 +610,7 @@ class DatePicker extends DateComponentBase {
}

get dateAriaDescription() {
return this.i18nBundle.getText(DATEPICKER_DATE_ACC_TEXT);
return this.i18nBundle.getText(DATEPICKER_DATE_DESCRIPTION);
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/Input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
?aria-invalid="{{accInfo.input.ariaInvalid}}"
aria-haspopup="{{accInfo.input.ariaHasPopup}}"
aria-describedby="{{accInfo.input.ariaDescribedBy}}"
aria-roledescription="{{accInfo.input.ariaRoledescription}}"
aria-autocomplete="{{accInfo.input.ariaAutoComplete}}"
aria-expanded="{{accInfo.input.ariaExpanded}}"
aria-label="{{accInfo.input.ariaLabel}}"
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@ class Input extends UI5Element {

return {
"input": {
"ariaRoledescription": this._inputAccInfo && (this._inputAccInfo.ariaRoledescription || undefined),
"ariaDescribedBy": ariaDescribedBy || undefined,
"ariaInvalid": this.valueState === ValueState.Error ? "true" : undefined,
"ariaHasPopup": this._inputAccInfo.ariaHasPopup ? this._inputAccInfo.ariaHasPopup : ariaHasPopupDefault,
Expand Down
6 changes: 3 additions & 3 deletions packages/main/src/i18n/messagebundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ BUTTON_ARIA_TYPE_REJECT=Negative Action
#XACT: ARIA announcement for the emphasized button
BUTTON_ARIA_TYPE_EMPHASIZED=Emphasized

#XACT: Date
DATEPICKER_DATE_ACC_TEXT=Date

# Carousel of text
CAROUSEL_OF_TEXT=of

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

#XACT: Aria information for the Date Picker
DATEPICKER_DATE_DESCRIPTION=Date Input

DELETE=Delete

FILEUPLOAD_BROWSE=Browse...
Expand Down
2 changes: 2 additions & 0 deletions packages/main/test/specs/DatePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ describe("Date Picker Tests", () => {

it("input renders", () => {
datepicker.id = "#dp";

assert.ok(datepicker.input.isDisplayedInViewport(), "input is rendered");
assert.ok(datepicker.innerInput.isDisplayedInViewport(), "inner input is rendered");
assert.strictEqual(datepicker.innerInput.getAttribute("aria-roledescription"), "Date Input", "aria-roledescription attribute is added.");
});

it("input receives value", () => {
Expand Down

0 comments on commit 70e3269

Please sign in to comment.