From a588ffe7ceadfb2fa26ce1bd1106f55420793d35 Mon Sep 17 00:00:00 2001 From: Filip Siderov Date: Fri, 12 Jun 2020 13:36:14 +0300 Subject: [PATCH] feat(ui5-input): implement aria-label (#1782) --- packages/main/src/Input.hbs | 1 + packages/main/src/Input.js | 10 ++++++++++ packages/main/test/pages/Input.html | 3 +++ packages/main/test/specs/Input.spec.js | 16 ++++++++++++++-- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/main/src/Input.hbs b/packages/main/src/Input.hbs index 4ebed8c263a0..a01d7da74ef3 100644 --- a/packages/main/src/Input.hbs +++ b/packages/main/src/Input.hbs @@ -23,6 +23,7 @@ aria-describedby="{{accInfo.input.ariaDescribedBy}}" aria-autocomplete="{{accInfo.input.ariaAutoComplete}}" aria-expanded="{{accInfo.input.ariaExpanded}}" + aria-label="{{accInfo.input.ariaLabel}}" @input="{{_handleInput}}" @change="{{_handleChange}}" @keydown="{{_onkeydown}}" diff --git a/packages/main/src/Input.js b/packages/main/src/Input.js index ff8cec61ced7..14c2929bd029 100644 --- a/packages/main/src/Input.js +++ b/packages/main/src/Input.js @@ -270,6 +270,15 @@ const metadata = { type: Integer, }, + /** + * @type {String} + * @since 1.0.0-rc.8 + * @public + */ + ariaLabel: { + type: String, + }, + /** * @private */ @@ -862,6 +871,7 @@ class Input extends UI5Element { "ariaOwns": this._inputAccInfo && this._inputAccInfo.ariaOwns, "ariaExpanded": this._inputAccInfo && this._inputAccInfo.ariaExpanded, "ariaDescription": this._inputAccInfo && this._inputAccInfo.ariaDescription, + "ariaLabel": this.ariaLabel, }, }; } diff --git a/packages/main/test/pages/Input.html b/packages/main/test/pages/Input.html index b9b1c4908b40..c793606aca84 100644 --- a/packages/main/test/pages/Input.html +++ b/packages/main/test/pages/Input.html @@ -158,6 +158,9 @@

Input type 'Tel'

Input type 'URL'

+

Input With aria-label

+ +

Inputs alignment

Press { assert.strictEqual(suggestionsInput.getValue(), "Cozy", "First item has been selected"); assert.strictEqual(inputResult.getValue(), "1", "suggestionItemSelected event called once"); - suggestionsInput.keys("c"); // to open the suggestions pop up once again + suggestionsInput.keys("c"); // to open the suggestions pop up once again suggestionsInput.keys("ArrowUp"); assert.strictEqual(suggestionsInput.getValue(), "Condensed", "First item has been selected"); @@ -230,11 +230,23 @@ describe("Input general interaction", () => { const respPopover = browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-responsive-popover .ui5-responsive-popover-header"); inputShadowRef.click(); - + assert.ok(popover.getProperty("opened"), "Popover with valueStateMessage should be opened."); inputShadowRef.keys("a"); assert.ok(respPopover, "Responsive popover with valueStateMessage should be opened."); }); + + it("Checks if aria-label is reflected in the shadow DOM", () => { + const input = browser.$("#aria-label-input"); + const innerInput = input.shadow$("input"); + const NEW_TEXT = "New cool text"; + + assert.strictEqual(input.getAttribute("aria-label"), innerInput.getAttribute("aria-label"), "aria-label is reflected in the shadow DOM") + + input.setAttribute("aria-label", NEW_TEXT); + + assert.strictEqual(innerInput.getAttribute("aria-label"), NEW_TEXT, "aria-label is reflected in the shadow DOM") + }); });