From 83fdef5f7690f36842f41d473a92cfd1a0446997 Mon Sep 17 00:00:00 2001
From: Petar Dimov <32839090+dimovpetar@users.noreply.github.com>
Date: Wed, 22 Dec 2021 13:59:05 +0200
Subject: [PATCH] feat(ui5-radio-button): implement accessibleNameRef property
(#4511)
---
packages/main/src/RadioButton.js | 18 +++++++++++++++---
packages/main/test/pages/RadioButton.html | 13 +++++++++++++
.../main/test/pages/styles/RadioButton.css | 6 ++++++
packages/main/test/specs/RadioButton.spec.js | 17 ++++++++++++++++-
4 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/packages/main/src/RadioButton.js b/packages/main/src/RadioButton.js
index 253606377ae7..76338fc71862 100644
--- a/packages/main/src/RadioButton.js
+++ b/packages/main/src/RadioButton.js
@@ -4,6 +4,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
+import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js";
import {
isSpace,
isEnter,
@@ -174,8 +175,7 @@ const metadata = {
},
/**
- * Defines the text alternative of the component.
- * If not provided a default text alternative will be set, if present.
+ * Defines the accessible name of the component.
*
* @type {string}
* @defaultvalue ""
@@ -186,6 +186,18 @@ const metadata = {
type: String,
},
+ /**
+ * Defines the IDs of the elements that label the component.
+ *
+ * @type {String}
+ * @defaultvalue ""
+ * @public
+ * @since 1.1.0
+ */
+ accessibleNameRef: {
+ type: String,
+ },
+
_tabIndex: {
type: String,
defaultValue: "-1",
@@ -455,7 +467,7 @@ class RadioButton extends UI5Element {
}
get ariaLabelText() {
- return [this.text, this.accessibleName].filter(Boolean).join(" ");
+ return [getEffectiveAriaLabelText(this), this.text].filter(Boolean).join(" ");
}
get ariaDescribedBy() {
diff --git a/packages/main/test/pages/RadioButton.html b/packages/main/test/pages/RadioButton.html
index e4c3a6405237..32e52a7bfcb6 100644
--- a/packages/main/test/pages/RadioButton.html
+++ b/packages/main/test/pages/RadioButton.html
@@ -89,11 +89,24 @@
*Params