Skip to content

Commit 387e418

Browse files
authored
fix(ui5-side-navigation): collapsed parent items appear as selected if one of its child items is selected (#11400)
* fix(ui5-side-navigation): collapsed parent items appear as selected if a child items is selected JIRA: BGSOFUIRODOPI-3383
1 parent 22f16c3 commit 387e418

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

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

+13-3
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ describe("Side Navigation interaction", () => {
122122
cy.mount(
123123
<SideNavigation>
124124
<SideNavigationItem id="item1" text="1" icon={group}>
125-
<SideNavigationSubItem text="1.1" />
126-
<SideNavigationSubItem text="1.2" />
125+
<SideNavigationSubItem id="subItem1" text="1.1" />
126+
<SideNavigationSubItem id="subItem2" text="1.2" />
127127
</SideNavigationItem>
128128
</SideNavigation>
129129
);
@@ -135,10 +135,20 @@ describe("Side Navigation interaction", () => {
135135
cy.get("#item1").should("have.attr", "expanded");
136136

137137
// act
138+
cy.get("#subItem1").realClick();
138139
cy.get("#item1").shadow().find(".ui5-sn-item-toggle-icon").realClick();
139140

140141
// assert
141142
cy.get("#item1").should("not.have.attr", "expanded");
143+
cy.get("#item1").shadow().find(".ui5-sn-item-level1").should("have.class", "ui5-sn-item-selected");
144+
cy.get("#item1").should("not.have.attr", "selected");
145+
146+
// act
147+
cy.get("#item1").shadow().find(".ui5-sn-item-toggle-icon").realClick();
148+
149+
// assert
150+
cy.get("#item1").shadow().find(".ui5-sn-item-level1").should("not.have.class", "ui5-sn-item-selected");
151+
142152
});
143153

144154
it("Tests expanding and collapsing of unselectable items", () => {
@@ -845,7 +855,7 @@ describe("Side Navigation Accessibility", () => {
845855
.shadow()
846856
.find(".ui5-sn-item-group")
847857
.should("have.attr", "role", "treeitem");
848-
858+
849859
cy.get("#group")
850860
.shadow()
851861
.find(".ui5-sn-item-group")

packages/fiori/src/SideNavigation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ class SideNavigation extends UI5Element {
601601

602602
this.overflowItems.forEach(item => {
603603
if (isInstanceOfSideNavigationItem(item) && item.classList.contains(overflowClass)) {
604-
result.push(item);
604+
result.push(item);
605605
}
606606
});
607607

packages/fiori/src/SideNavigationItem.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class SideNavigationItem extends SideNavigationSelectableItemBase {
172172
}
173173

174174
get _selected() {
175-
if (this.sideNavCollapsed) {
175+
if (this.sideNavCollapsed || !this.expanded) {
176176
return this.selected || this.items.some(item => item.selected);
177177
}
178178

0 commit comments

Comments
 (0)