Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement assessibleNameRef for many components #3442

Merged
merged 15 commits into from
Jul 30, 2021
2 changes: 1 addition & 1 deletion packages/base/hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Jo7xX6Xqjqd/+p/wSl0hl57d8ng=
44n+tz3Upvb7fx9BuRR5JpZRssg=
4 changes: 2 additions & 2 deletions packages/base/src/util/AriaLabelHelper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import findNodeOwner from "./findNodeOwner.js";

const getEffectiveAriaLabelText = el => {
if (!el.ariaLabelledby) {
if (!el.accessibleNameRef) {
if (el.accessibleName) {
return el.accessibleName;
}
Expand All @@ -19,7 +19,7 @@ const getEffectiveAriaLabelText = el => {
* @param {String} readyIds (Optional) Defines a string of elements ids. The text of these elements will be returned. If used you should provide either el or ownerDocument
*/
const getAriaLabelledByTexts = (el, ownerDocument, readyIds = "") => {
const ids = (readyIds && readyIds.split(" ")) || el.ariaLabelledby.split(" ");
const ids = (readyIds && readyIds.split(" ")) || el.accessibleNameRef.split(" ");
const owner = ownerDocument || findNodeOwner(el);
let result = "";

Expand Down
2 changes: 1 addition & 1 deletion packages/fiori/src/NotificationListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const metadata = {
* @type {WrappingType}
* @defaultvalue "None"
* @public
* @since 1.0.0-rc.16
* @since 1.0.0-rc.15
*/
wrappingType: {
type: WrappingType,
Expand Down
5 changes: 3 additions & 2 deletions packages/fiori/src/WizardStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ const metadata = {
* Defines the aria-labelledby of the step.
* @type {boolean}
* @defaultvalue ""
* @private
* @public
* @since 1.0.0-rc.15
*/
ariaLabelledby: {
accessibleNameRef: {
type: String,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/Button.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
aria-expanded="{{accInfo.ariaExpanded}}"
aria-controls="{{accInfo.ariaControls}}"
aria-haspopup="{{accInfo.ariaHaspopup}}"
aria-label="{{ariaLabelText}}"
aria-label="{{accessibleName}}"
title="{{accInfo.title}}"
part="button"
>
Expand Down
17 changes: 0 additions & 17 deletions packages/main/src/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js";
import isLegacyBrowser from "@ui5/webcomponents-base/dist/isLegacyBrowser.js";
import { isPhone, isTablet } from "@ui5/webcomponents-base/dist/Device.js";
import ButtonDesign from "./types/ButtonDesign.js";
Expand Down Expand Up @@ -165,18 +164,6 @@ const metadata = {
defaultValue: undefined,
},

/**
* Receives id(or many ids) of the elements that label the button
* @type {String}
* @defaultvalue ""
* @private
* @since 1.0.0-rc.7
*/
ariaLabelledby: {
type: String,
defaultValue: "",
},

/**
* @type {String}
* @defaultvalue ""
Expand Down Expand Up @@ -443,10 +430,6 @@ class Button extends UI5Element {
};
}

get ariaLabelText() {
return getEffectiveAriaLabelText(this);
}

static typeTextMappings() {
return {
"Positive": BUTTON_ARIA_TYPE_ACCEPT,
Expand Down
5 changes: 1 addition & 4 deletions packages/main/src/Card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
class="{{classes}}"
dir="{{effectiveDir}}"
role="region"
aria-label="{{ariaLabelText}}"
aria-labelledby="{{ariaLabelledByCard}}"
>
<!-- header -->
aria-labelledby="{{ariaLabelledByCard}}">
{{#if hasHeader}}
<div class="ui5-card-header-root">
<slot name="header"></slot>
Expand Down
31 changes: 2 additions & 29 deletions packages/main/src/Card.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js";
import CardTemplate from "./generated/templates/CardTemplate.lit.js";
import Icon from "./Icon.js";

Expand Down Expand Up @@ -48,32 +47,10 @@ const metadata = {
},
properties: /** @lends sap.ui.webcomponents.main.Card.prototype */ {

/**
* Sets the accessible aria name of the component.
*
* @type {String}
* @public
* @since 1.0.0-rc.15
* @defaultvalue ""
*/
accessibleName: {
type: String,
},
},
events: /** @lends sap.ui.webcomponents.main.Card.prototype */ {

/**
* Receives id(or many ids) of the elements that label the component
*
* @type {String}
* @defaultvalue ""
* @private
* @since 1.0.0-rc.9
*/
ariaLabelledby: {
type: String,
defaultValue: "",
},
},
events: /** @lends sap.ui.webcomponents.main.Card.prototype */ {},
};

/**
Expand Down Expand Up @@ -138,10 +115,6 @@ class Card extends UI5Element {
return !!this.header.length;
}

get ariaLabelText() {
return getEffectiveAriaLabelText(this);
}

get ariaCardRoleDescription() {
return this.i18nBundle.getText(ARIA_ROLEDESCRIPTION_CARD);
}
Expand Down
28 changes: 0 additions & 28 deletions packages/main/src/CardHeader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js";
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
import CardHeaderTemplate from "./generated/templates/CardHeaderTemplate.lit.js";
import Icon from "./Icon.js";
Expand Down Expand Up @@ -93,29 +92,6 @@ const metadata = {
type: Boolean,
},

/**
* Defines the aria-label attribute for the component
*
* @type {String}
* @private
* @defaultvalue ""
*/
ariaLabel: {
type: String,
},

/**
* Receives id(or many ids) of the elements that label the component
*
* @type {String}
* @defaultvalue ""
* @private
*/
ariaLabelledby: {
type: String,
defaultValue: "",
},

_headerActive: {
type: Boolean,
noAttribute: true,
Expand Down Expand Up @@ -208,10 +184,6 @@ class CardHeader extends UI5Element {
return this.interactive ? undefined : "3";
}

get ariaLabelText() {
return getEffectiveAriaLabelText(this);
}

get ariaCardHeaderRoleDescription() {
return this.interactive ? this.i18nBundle.getText(ARIA_ROLEDESCRIPTION_INTERACTIVE_CARD_HEADER) : this.i18nBundle.getText(ARIA_ROLEDESCRIPTION_CARD_HEADER);
}
Expand Down
1 change: 0 additions & 1 deletion packages/main/src/CheckBox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
aria-checked="{{ariaChecked}}"
aria-readonly="{{ariaReadonly}}"
aria-disabled="{{ariaDisabled}}"
aria-label="{{ariaLabelText}}"
aria-labelledby="{{ariaLabelledBy}}"
aria-describedby="{{ariaDescribedBy}}"
tabindex="{{tabIndex}}"
Expand Down
36 changes: 1 addition & 35 deletions packages/main/src/CheckBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { isDesktop } from "@ui5/webcomponents-base/dist/Device.js";
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js";
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js";
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
Expand Down Expand Up @@ -164,31 +163,6 @@ const metadata = {
name: {
type: String,
},

/**
* Sets the accessible aria name of the component.
*
* @type {string}
* @defaultvalue undefined
* @public
* @since 1.0.0-rc.15
*/
accessibleName: {
type: String,
defaultValue: undefined,
},

/**
* Receives id(or many ids) of the elements that label the checkbox
* @type {String}
* @defaultvalue ""
* @private
* @since 1.0.0-rc.9
*/
ariaLabelledby: {
type: String,
defaultValue: "",
},
},
events: /** @lends sap.ui.webcomponents.main.CheckBox.prototype */ {

Expand Down Expand Up @@ -365,20 +339,12 @@ class CheckBox extends UI5Element {
return this.disabled ? "true" : undefined;
}

get ariaLabelText() {
return getEffectiveAriaLabelText(this);
}

get ariaChecked() {
return this.indeterminate && this.checked ? "mixed" : this.checked;
}

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

return undefined;
return this.text ? `${this._id}-label` : undefined;
}

get ariaDescribedBy() {
Expand Down
6 changes: 3 additions & 3 deletions packages/main/src/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ const metadata = {
* Receives id(or many ids) of the elements that label the combo box
* @type {String}
* @defaultvalue ""
* @private
* @since 1.0.0-rc.8
* @public
* @since 1.0.0-rc.15
*/
ariaLabelledby: {
accessibleNameRef: {
type: String,
defaultValue: "",
},
Expand Down
6 changes: 3 additions & 3 deletions packages/main/src/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ const metadata = {
*
* @type {String}
* @defaultvalue ""
* @private
* @since 1.0.0-rc.9
* @public
* @since 1.0.0-rc.15
*/
ariaLabelledby: {
accessibleNameRef: {
type: String,
defaultValue: "",
},
Expand Down
6 changes: 3 additions & 3 deletions packages/main/src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ const metadata = {
*
* @type {String}
* @defaultvalue ""
* @private
* @since 1.0.0-rc.8
* @public
* @since 1.0.0-rc.15
*/
ariaLabelledby: {
accessibleNameRef: {
type: String,
defaultValue: "",
},
Expand Down
21 changes: 5 additions & 16 deletions packages/main/src/Link.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js";
import { getAriaLabelledByTexts } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import LinkDesign from "./types/LinkDesign.js";
import WrappingType from "./types/WrappingType.js";
Expand Down Expand Up @@ -102,26 +102,15 @@ const metadata = {
defaultValue: WrappingType.None,
},

/**
* Sets the accessible aria name of the component.
*
* @type {String}
* @public
* @since 1.0.0-rc.15
*/
accessibleName: {
type: String,
},

/**
* Receives id(or many ids) of the elements that label the input
*
* @type {String}
* @defaultvalue ""
* @private
* @since 1.0.0-rc.10
* @public
* @since 1.0.0-rc.15
*/
ariaLabelledby: {
accessibleNameRef: {
ilhan007 marked this conversation as resolved.
Show resolved Hide resolved
type: String,
defaultValue: "",
},
Expand Down Expand Up @@ -244,7 +233,7 @@ class Link extends UI5Element {
}

get ariaLabelText() {
return getEffectiveAriaLabelText(this);
return getAriaLabelledByTexts(this);
}

get hasLinkType() {
Expand Down
8 changes: 4 additions & 4 deletions packages/main/src/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ const metadata = {
*
* @type {String}
* @defaultvalue ""
* @private
* @since 1.0.0-rc.8
* @public
* @since 1.0.0-rc.15
*/
ariaLabelledby: {
accessibleNameRef: {
type: String,
defaultValue: "",
},
Expand Down Expand Up @@ -525,7 +525,7 @@ class List extends UI5Element {
}

get ariaLabelledBy() {
if (this.ariaLabelledby || this.accessibleName) {
if (this.accessibleNameRef || this.accessibleName) {
return undefined;
}

Expand Down
Loading