From 7e65e77e020f62f1de2be55e6bc0a6216b859909 Mon Sep 17 00:00:00 2001 From: ilhan orhan Date: Fri, 23 Oct 2020 11:59:17 +0300 Subject: [PATCH] feat(ui5-link): add aria-label and aria-labelledby support (#2357) FIXES: #2356 --- packages/main/src/Link.hbs | 1 + packages/main/src/Link.js | 31 +++++++++++++++++++++++++++ packages/main/test/pages/Link.html | 6 ++++++ packages/main/test/specs/Link.spec.js | 27 +++++++++++++++++------ 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/packages/main/src/Link.hbs b/packages/main/src/Link.hbs index 87745856bb8a..c7a9796e6ed4 100644 --- a/packages/main/src/Link.hbs +++ b/packages/main/src/Link.hbs @@ -7,6 +7,7 @@ tabindex="{{tabIndex}}" ?disabled="{{disabled}}" aria-disabled="{{ariaDisabled}}" + aria-label="{{ariaLabelText}}" @focusin={{_onfocusin}} @click={{_onclick}} @keydown={{_onkeydown}} diff --git a/packages/main/src/Link.js b/packages/main/src/Link.js index 548911db9e18..ffc039d71b79 100644 --- a/packages/main/src/Link.js +++ b/packages/main/src/Link.js @@ -1,8 +1,10 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js"; import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js"; +import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js"; import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js"; import LinkDesign from "./types/LinkDesign.js"; + // Template import LinkRederer from "./generated/templates/LinkTemplate.lit.js"; @@ -91,6 +93,31 @@ const metadata = { type: Boolean, }, + /** + * Defines the aria-label attribute for the link. + * + * @type {String} + * @since 1.0.0-rc.10 + * @private + * @defaultvalue "" + */ + ariaLabel: { + type: String, + }, + + /** + * Receives id(or many ids) of the elements that label the input + * + * @type {String} + * @defaultvalue "" + * @private + * @since 1.0.0-rc.10 + */ + ariaLabelledby: { + type: String, + defaultValue: "", + }, + _rel: { type: String, noAttribute: true, @@ -211,6 +238,10 @@ class Link extends UI5Element { return this.disabled ? "true" : undefined; } + get ariaLabelText() { + return getEffectiveAriaLabelText(this); + } + get hasLinkType() { return this.design !== LinkDesign.Default; } diff --git a/packages/main/test/pages/Link.html b/packages/main/test/pages/Link.html index 0de992c809da..d3dad5963efc 100644 --- a/packages/main/test/pages/Link.html +++ b/packages/main/test/pages/Link.html @@ -79,6 +79,12 @@

Link designs

+
+ + Go to + Go to +
+