Skip to content

Commit a588ffe

Browse files
authored
feat(ui5-input): implement aria-label (#1782)
1 parent df9e4e9 commit a588ffe

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

packages/main/src/Input.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
aria-describedby="{{accInfo.input.ariaDescribedBy}}"
2424
aria-autocomplete="{{accInfo.input.ariaAutoComplete}}"
2525
aria-expanded="{{accInfo.input.ariaExpanded}}"
26+
aria-label="{{accInfo.input.ariaLabel}}"
2627
@input="{{_handleInput}}"
2728
@change="{{_handleChange}}"
2829
@keydown="{{_onkeydown}}"

packages/main/src/Input.js

+10
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,15 @@ const metadata = {
270270
type: Integer,
271271
},
272272

273+
/**
274+
* @type {String}
275+
* @since 1.0.0-rc.8
276+
* @public
277+
*/
278+
ariaLabel: {
279+
type: String,
280+
},
281+
273282
/**
274283
* @private
275284
*/
@@ -862,6 +871,7 @@ class Input extends UI5Element {
862871
"ariaOwns": this._inputAccInfo && this._inputAccInfo.ariaOwns,
863872
"ariaExpanded": this._inputAccInfo && this._inputAccInfo.ariaExpanded,
864873
"ariaDescription": this._inputAccInfo && this._inputAccInfo.ariaDescription,
874+
"ariaLabel": this.ariaLabel,
865875
},
866876
};
867877
}

packages/main/test/pages/Input.html

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ <h3> Input type 'Tel'</h3>
158158
<h3> Input type 'URL'</h3>
159159
<ui5-input id="input-url" type="URL"></ui5-input>
160160

161+
<h3> Input With aria-label</h3>
162+
<ui5-input id="aria-label-input" aria-label="Enter your secret password"></ui5-input>
163+
161164
<h3> Inputs alignment</h3>
162165
<ui5-button>Press</ui5-button>
163166
<ui5-datepicker id='dp5'

packages/main/test/specs/Input.spec.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe("Input general interaction", () => {
186186
assert.strictEqual(suggestionsInput.getValue(), "Cozy", "First item has been selected");
187187
assert.strictEqual(inputResult.getValue(), "1", "suggestionItemSelected event called once");
188188

189-
suggestionsInput.keys("c"); // to open the suggestions pop up once again
189+
suggestionsInput.keys("c"); // to open the suggestions pop up once again
190190
suggestionsInput.keys("ArrowUp");
191191

192192
assert.strictEqual(suggestionsInput.getValue(), "Condensed", "First item has been selected");
@@ -230,11 +230,23 @@ describe("Input general interaction", () => {
230230
const respPopover = browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-responsive-popover .ui5-responsive-popover-header");
231231

232232
inputShadowRef.click();
233-
233+
234234
assert.ok(popover.getProperty("opened"), "Popover with valueStateMessage should be opened.");
235235

236236
inputShadowRef.keys("a");
237237

238238
assert.ok(respPopover, "Responsive popover with valueStateMessage should be opened.");
239239
});
240+
241+
it("Checks if aria-label is reflected in the shadow DOM", () => {
242+
const input = browser.$("#aria-label-input");
243+
const innerInput = input.shadow$("input");
244+
const NEW_TEXT = "New cool text";
245+
246+
assert.strictEqual(input.getAttribute("aria-label"), innerInput.getAttribute("aria-label"), "aria-label is reflected in the shadow DOM")
247+
248+
input.setAttribute("aria-label", NEW_TEXT);
249+
250+
assert.strictEqual(innerInput.getAttribute("aria-label"), NEW_TEXT, "aria-label is reflected in the shadow DOM")
251+
});
240252
});

0 commit comments

Comments
 (0)