Skip to content

Commit dc78e89

Browse files
Merge branch 'main' into user-menu-item
2 parents bc4d92d + 9c0d1c3 commit dc78e89

3 files changed

Lines changed: 83 additions & 7 deletions

File tree

packages/main/cypress/specs/Input.cy.tsx

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Link from "../../src/Link.js";
77

88
import add from "@ui5/webcomponents-icons/dist/add.js";
99
import type ResponsivePopover from "../../src/ResponsivePopover.js";
10+
import { INPUT_SUGGESTIONS_EXPANDED, INPUT_SUGGESTIONS_COLLAPSED, INPUT_SUGGESTIONS_MORE_HITS } from "../../src/generated/i18n/i18n-defaults.js";
1011

1112
describe("Input Tests", () => {
1213
it("test input event prevention", () => {
@@ -1364,6 +1365,71 @@ describe("Accessibility", () => {
13641365
});
13651366
});
13661367

1368+
describe("Suggestions expanded/collapsed announcement", () => {
1369+
it("Should include 'Expanded' in suggestions count when popover opens", () => {
1370+
cy.mount(
1371+
<Input showSuggestions>
1372+
<SuggestionItem text="Item 1" />
1373+
<SuggestionItem text="Item 2" />
1374+
</Input>
1375+
);
1376+
1377+
cy.get("[ui5-input]")
1378+
.as("input")
1379+
.realClick();
1380+
1381+
cy.get("@input")
1382+
.shadow()
1383+
.find("input")
1384+
.realType("I");
1385+
1386+
cy.get("@input")
1387+
.shadow()
1388+
.find<ResponsivePopover>("[ui5-responsive-popover]")
1389+
.ui5ResponsivePopoverOpened();
1390+
1391+
cy.get("@input")
1392+
.shadow()
1393+
.find("#suggestionsCount")
1394+
.should("contain.text", INPUT_SUGGESTIONS_EXPANDED.defaultText);
1395+
});
1396+
1397+
it("Should announce 'Collapsed' when suggestions popover closes", () => {
1398+
cy.mount(
1399+
<Input showSuggestions>
1400+
<SuggestionItem text="Item 1" />
1401+
<SuggestionItem text="Item 2" />
1402+
</Input>
1403+
);
1404+
1405+
cy.get("[ui5-input]")
1406+
.as("input")
1407+
.realClick();
1408+
1409+
cy.get("@input")
1410+
.shadow()
1411+
.find("input")
1412+
.realType("I");
1413+
1414+
cy.get("@input")
1415+
.shadow()
1416+
.find<ResponsivePopover>("[ui5-responsive-popover]")
1417+
.ui5ResponsivePopoverOpened();
1418+
1419+
cy.realPress("Escape");
1420+
1421+
cy.get("@input")
1422+
.shadow()
1423+
.find<ResponsivePopover>("[ui5-responsive-popover]")
1424+
.ui5ResponsivePopoverClosed();
1425+
1426+
cy.get("@input")
1427+
.shadow()
1428+
.find("#suggestionsCount")
1429+
.should("contain.text", INPUT_SUGGESTIONS_COLLAPSED.defaultText);
1430+
});
1431+
});
1432+
13671433
describe("Attribute propagation", () => {
13681434
it("Should change the placeholder of the inner input", () => {
13691435
const placeholder = "New placeholder text";
@@ -2134,17 +2200,17 @@ describe("Input general interaction", () => {
21342200
);
21352201

21362202
cy.get("#inputCompact").click();
2137-
cy.get("#inputCompact").shadow().find("#suggestionsCount").should("have.text", "");
2203+
cy.get("#inputCompact").shadow().find("#suggestionsCount").should("have.text", "Collapsed");
21382204

21392205
cy.get("#inputCompact").shadow().find("input").realType("c");
2140-
cy.get("#inputCompact").shadow().find("#suggestionsCount").should("have.text", "3 results are available");
2206+
cy.get("#inputCompact").shadow().find("#suggestionsCount").should("have.text", "3 results are available Expanded");
21412207

21422208
cy.get("#inputCompact").shadow().find("input").realType("{backspace}");
21432209
cy.get("#inputCompact").shadow().find("input").realType("{esc}");
21442210

21452211
cy.get("#myInput2").click();
21462212
cy.get("#myInput2").shadow().find("input").realType("c");
2147-
cy.get("#myInput2").shadow().find("#suggestionsCount").should("have.text", "5 results are available");
2213+
cy.get("#myInput2").shadow().find("#suggestionsCount").should("have.text", "5 results are available Expanded");
21482214
});
21492215

21502216
it("Should close the Popover when no suggestions are available", () => {

packages/main/src/Input.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ import {
8989
INPUT_AVALIABLE_VALUES,
9090
INPUT_SUGGESTIONS_OK_BUTTON,
9191
INPUT_SUGGESTIONS_CANCEL_BUTTON,
92+
INPUT_SUGGESTIONS_EXPANDED,
93+
INPUT_SUGGESTIONS_COLLAPSED,
9294
} from "./generated/i18n/i18n-defaults.js";
9395

9496
// Styles
@@ -1987,20 +1989,22 @@ class Input extends UI5Element implements SuggestionComponent, IFormInputElement
19871989
get availableSuggestionsCount() {
19881990
if (this.showSuggestions && (this.value || this.Suggestions?.isOpened())) {
19891991
const nonGroupItems = this._selectableItems;
1992+
const isOpened = this.Suggestions?.isOpened();
1993+
const stateText = isOpened ? Input.i18nBundle.getText(INPUT_SUGGESTIONS_EXPANDED) : Input.i18nBundle.getText(INPUT_SUGGESTIONS_COLLAPSED);
19901994

19911995
switch (nonGroupItems.length) {
19921996
case 0:
1993-
return Input.i18nBundle.getText(INPUT_SUGGESTIONS_NO_HIT);
1997+
return `${Input.i18nBundle.getText(INPUT_SUGGESTIONS_NO_HIT)} ${stateText}`;
19941998

19951999
case 1:
1996-
return Input.i18nBundle.getText(INPUT_SUGGESTIONS_ONE_HIT);
2000+
return `${Input.i18nBundle.getText(INPUT_SUGGESTIONS_ONE_HIT)} ${stateText}`;
19972001

19982002
default:
1999-
return Input.i18nBundle.getText(INPUT_SUGGESTIONS_MORE_HITS, nonGroupItems.length);
2003+
return `${Input.i18nBundle.getText(INPUT_SUGGESTIONS_MORE_HITS, nonGroupItems.length)} ${stateText}`;
20002004
}
20012005
}
20022006

2003-
return undefined;
2007+
return this.showSuggestions ? Input.i18nBundle.getText(INPUT_SUGGESTIONS_COLLAPSED) : undefined;
20042008
}
20052009

20062010
get step() {

packages/main/src/i18n/messagebundle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ INPUT_SUGGESTIONS_MORE_HITS={0} results are available
342342
#XACT: ARIA announcement for the Input suggestion result if no hit
343343
INPUT_SUGGESTIONS_NO_HIT=No results
344344

345+
#XACT: ARIA announcement when suggestions popover is expanded
346+
INPUT_SUGGESTIONS_EXPANDED=Expanded
347+
348+
#XACT: ARIA announcement when suggestions popover is collapsed
349+
INPUT_SUGGESTIONS_COLLAPSED=Collapsed
350+
345351
#XACT: ARIA label for the Input clear icon
346352
INPUT_CLEAR_ICON_ACC_NAME=Clear
347353

0 commit comments

Comments
 (0)