Skip to content

Commit 76ec379

Browse files
authored
fix(ui5-input): Suggestions count is read out when expected (#3127)
On accessing the ui5-input web component, the suggestions count should not be read out. It is expected to be read out, once the suggestions are opened or after entering a value. FIXES: #3051
1 parent a2c8fce commit 76ec379

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

packages/main/src/Input.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1080,14 +1080,10 @@ class Input extends UI5Element {
10801080
return this.hasValueState ? `${this._id}-valueStateDesc` : "";
10811081
}
10821082

1083-
get suggestionsCount() {
1084-
return this.showSuggestions ? `${this._id}-suggestionsCount` : "";
1085-
}
1086-
10871083
get accInfo() {
10881084
const ariaHasPopupDefault = this.showSuggestions ? "true" : undefined;
10891085
const ariaAutoCompleteDefault = this.showSuggestions ? "list" : undefined;
1090-
const ariaDescribedBy = this._inputAccInfo.ariaDescribedBy ? `${this.suggestionsTextId} ${this.valueStateTextId} ${this.suggestionsCount} ${this._inputAccInfo.ariaDescribedBy}`.trim() : `${this.suggestionsTextId} ${this.valueStateTextId} ${this.suggestionsCount}`.trim();
1086+
const ariaDescribedBy = this._inputAccInfo.ariaDescribedBy ? `${this.suggestionsTextId} ${this.valueStateTextId} ${this._inputAccInfo.ariaDescribedBy}`.trim() : `${this.suggestionsTextId} ${this.valueStateTextId}`.trim();
10911087

10921088
return {
10931089
"input": {
@@ -1200,7 +1196,7 @@ class Input extends UI5Element {
12001196
}
12011197

12021198
get availableSuggestionsCount() {
1203-
if (this.showSuggestions) {
1199+
if (this.showSuggestions && (this.value || this.Suggestions.isOpened())) {
12041200
switch (this.suggestionsTexts.length) {
12051201
case 0:
12061202
return this.i18nBundle.getText(INPUT_SUGGESTIONS_NO_HIT);

packages/main/src/MultiInput.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class MultiInput extends Input {
280280
}
281281

282282
get accInfo() {
283-
const ariaDescribedBy = `${this._tokensCountTextId} ${this.suggestionsTextId} ${this.valueStateTextId} ${this.suggestionsCount}`.trim();
283+
const ariaDescribedBy = `${this._tokensCountTextId} ${this.suggestionsTextId} ${this.valueStateTextId}`.trim();
284284
return {
285285
"input": {
286286
...super.accInfo.input,

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

+28
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,32 @@ describe("Input general interaction", () => {
458458
assert.notOk(popover.isDisplayedInViewport(), "The popover is not visible");
459459
assert.ok(dialog.isDisplayedInViewport(), "The dialog is opened.");
460460
});
461+
462+
it("Suggestions count should be read out when necessary", () => {
463+
browser.url(`http://localhost:${PORT}/test-resources/pages/Input.html`);
464+
465+
const inputDynamicSuggestions = $("#inputCompact");
466+
const inputSuggestions = $("#myInput2");
467+
const dynamicSuggestionsInnerInput = inputDynamicSuggestions.shadow$("input");
468+
const dynamicSuggestionsCount = inputDynamicSuggestions.shadow$(`#${inputDynamicSuggestions.getProperty("_id")}-suggestionsCount`);
469+
const suggestionsCount = inputSuggestions.shadow$(`#${inputSuggestions.getProperty("_id")}-suggestionsCount`);
470+
471+
//act
472+
dynamicSuggestionsInnerInput.click();
473+
474+
//assert
475+
assert.strictEqual(dynamicSuggestionsCount.getText(), "", "Suggestions count is not available");
476+
477+
//act
478+
dynamicSuggestionsInnerInput.keys("c");
479+
480+
//assert
481+
assert.strictEqual(dynamicSuggestionsCount.getText(), "4 results are available", "Suggestions count is available since value is entered");
482+
dynamicSuggestionsInnerInput.keys("Backspace");
483+
//act
484+
inputSuggestions.click();
485+
486+
//assert
487+
assert.strictEqual(suggestionsCount.getText(), "5 results are available", "Suggestions count is available since the suggestions popover is opened");
488+
});
461489
});

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ describe("ARIA attributes", () => {
175175
const innerInput = mi.shadow$("input");
176176
const tokensCountITextId = `${mi.getProperty("_id")}-hiddenText-nMore`;
177177
const suggestionsITextId = `${mi.getProperty("_id")}-suggestionsText`;
178-
const suggestionsCountITextId = `${mi.getProperty("_id")}-suggestionsCount`;
179-
const ariaDescribedBy = `${tokensCountITextId} ${suggestionsITextId} ${suggestionsCountITextId}`;
178+
const ariaDescribedBy = `${tokensCountITextId} ${suggestionsITextId}`;
180179

181180
$("#suggestion-token").scrollIntoView();
182181
innerInput.click();

0 commit comments

Comments
 (0)