Skip to content

Commit 452b233

Browse files
committed
fix(ui5-shellbar-search): focus on first suggestion item
1 parent 0cee9f7 commit 452b233

File tree

4 files changed

+75
-5
lines changed

4 files changed

+75
-5
lines changed

packages/fiori/cypress/specs/Search.cy.tsx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,76 @@ describe("Properties", () => {
8888
.should("be.focused");
8989
});
9090

91+
it("items slot arrow down navigation with groups and headerText", () => {
92+
cy.mount(
93+
<Search>
94+
<SearchItemGroup headerText="Group Header 1">
95+
<SearchItem text="List Item" icon={history}></SearchItem>
96+
<SearchItem text="List Item" icon={searchIcon}></SearchItem>
97+
</SearchItemGroup>
98+
</Search>
99+
);
100+
101+
cy.get("[ui5-search]")
102+
.shadow()
103+
.find("input")
104+
.realClick();
105+
106+
cy.get("[ui5-search]")
107+
.realPress("L");
108+
109+
cy.get("[ui5-search]")
110+
.should("be.focused");
111+
112+
cy.get("[ui5-search]")
113+
.realPress("ArrowDown");
114+
115+
cy.get("ui5-search-item-group")
116+
.shadow()
117+
.find("ui5-li-group-header")
118+
.should("be.focused");
119+
120+
cy.get("[ui5-search]")
121+
.realPress("ArrowUp");
122+
123+
cy.get("[ui5-search]")
124+
.should("be.focused");
125+
});
126+
127+
it.only("items slot arrow down navigation with groups and no headerText", () => {
128+
cy.mount(
129+
<Search>
130+
<SearchItemGroup>
131+
<SearchItem text="List Item" icon={history}></SearchItem>
132+
<SearchItem text="List Item" icon={searchIcon}></SearchItem>
133+
</SearchItemGroup>
134+
</Search>
135+
);
136+
137+
cy.get("[ui5-search]")
138+
.shadow()
139+
.find("input")
140+
.realClick();
141+
142+
cy.get("[ui5-search]")
143+
.realPress("L");
144+
145+
cy.get("[ui5-search]")
146+
.should("be.focused");
147+
148+
cy.get("[ui5-search]")
149+
.realPress("ArrowDown");
150+
151+
cy.get("ui5-search-item").eq(0)
152+
.should("be.focused");
153+
154+
cy.get("[ui5-search]")
155+
.realPress("ArrowUp");
156+
157+
cy.get("[ui5-search]")
158+
.should("be.focused");
159+
})
160+
91161
it("items should be shown instead of illustration of both present ", () => {
92162
cy.mount(
93163
<Search>

packages/fiori/src/Search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ class Search extends SearchField {
354354
}
355355

356356
_handleArrowDown() {
357-
const firstListItem = this._getItemsList()?.getSlottedNodes<ISearchSuggestionItem>("items")[0];
357+
const firstListItem = this._getItemsList()?.listItems?.[0];
358358

359359
if (this.open) {
360360
this._deselectItems();

packages/fiori/src/SearchItemGroup.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ class SearchItemGroup extends ListItemGroup {
2626
get isGroupItem(): boolean {
2727
return true;
2828
}
29-
30-
getFocusDomRef() {
31-
return this.shadowRoot!.querySelector("[ui5-li-group-header]") as ListItemGroupHeader;
32-
}
3329
}
3430

3531
SearchItemGroup.define();

packages/main/src/ListItemGroup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ class ListItemGroup extends UI5Element {
232232

233233
this.dropIndicatorDOM!.targetReference = null;
234234
}
235+
236+
getFocusDomRef() {
237+
return this.groupHeaderItem || this.items[0];
238+
}
235239
}
236240

237241
ListItemGroup.define();

0 commit comments

Comments
 (0)