Skip to content

Commit 239c451

Browse files
s-todorovaGerrit Code Review
authored andcommitted
Merge "[FIX] sap.tnt.NavigationList: Application of sapTntNLISelected class is corrected"
2 parents a79cb08 + 6aa88fa commit 239c451

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/sap.tnt/src/sap/tnt/NavigationList.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,14 @@ sap.ui.define([
546546
let oSelectedItem;
547547
if (this._selectedItem) {
548548
this._selectedItem._toggle(false);
549+
550+
const oPrevParent = this._selectedItem.getParent();
551+
if (oPrevParent && oPrevParent.isA && oPrevParent.isA("sap.tnt.NavigationListItem") &&
552+
oPrevParent.getExpanded() === false && oPrevParent._getVisibleItems(oPrevParent).includes(this._selectedItem)) {
553+
if (!oPrevParent._getVisibleItems(oPrevParent).includes(oItem)) {
554+
oPrevParent._toggle(false);
555+
}
556+
}
549557
}
550558

551559
if (!oItem) {

src/sap.tnt/test/sap/tnt/qunit/NavigationList.qunit.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,31 @@ sap.ui.define([
18371837
assert.notOk(oDefaultItem.classList.contains("sapTntNLITwoClickAreas"), "sapTntNLITwoClickAreas class is not set when item has no children");
18381838
});
18391839

1840+
QUnit.test("correct application of sapTntNLISelected class", async function (assert) {
1841+
1842+
const oUnselectableParent = this.navigationList.getItems()[0];
1843+
const oUnselectableParentDomRef = oUnselectableParent.getDomRef().querySelector(".sapTntNLI");
1844+
const oChildOfUnselectableParent = this.navigationList.getItems()[0].getItems()[0];
1845+
const oChildOfUnselectableParentDomRef = this.navigationList.getItems()[0].getItems()[0].getDomRef();
1846+
const oDefaultItem = this.navigationList.getItems()[3];
1847+
const oDefaultItemDomRef = oDefaultItem.getDomRef().querySelector(".sapTntNLI");
1848+
1849+
QUnitUtils.triggerEvent("tap", oChildOfUnselectableParentDomRef);
1850+
oUnselectableParent.setExpanded(false);
1851+
await nextUIUpdate();
1852+
1853+
assert.equal(oUnselectableParent.getExpanded(), false, "Unselectable parent is collapsed");
1854+
assert.equal(this.navigationList.getSelectedItem(), oChildOfUnselectableParent, "Selected item is the child");
1855+
assert.ok(oUnselectableParentDomRef.classList.contains("sapTntNLISelected"), "sapTntNLISelected class is set on the collapsed parent");
1856+
1857+
QUnitUtils.triggerEvent("tap", oDefaultItemDomRef);
1858+
await nextUIUpdate();
1859+
1860+
assert.equal(this.navigationList.getSelectedItem(), oDefaultItem, "Selected item is the new one");
1861+
assert.ok(oDefaultItemDomRef.classList.contains("sapTntNLISelected"), "sapTntNLISelected class is set on the newly selected item");
1862+
assert.notOk(oUnselectableParentDomRef.classList.contains("sapTntNLISelected"), "sapTntNLISelected class is not set on the previously selected item's parent");
1863+
});
1864+
18401865
QUnit.test("Design Action", function (assert) {
18411866

18421867
const oActionItem = this.navigationList.getItems()[2].getDomRef().querySelector(".sapTntNLI");

0 commit comments

Comments
 (0)