Skip to content

Commit a89de1a

Browse files
authored
fix(ui5-tabcontainer): left arrow correctly scrolls to left in textOnly (#97)
Fixes: #94
1 parent 969903d commit a89de1a

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

packages/main/src/TabContainer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ class TabContainer extends WebComponent {
755755
}
756756

757757
_navigationIconPress(icon) {
758-
if (icon.classList.contains("sapMITBArrowScrollLeft")) {
758+
if (icon.classList.contains("sapMITBArrowScrollLeft") || icon.classList.contains("sapMITBArrowScrollLeftTextOnly")) {
759759
this._leftArrow.onPress();
760760
} else {
761761
this._rightArrow.onPress();

packages/main/test/sap/ui/webcomponents/main/pages/TabContainer.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ <h5>Horizontal design</h5>
103103
</ui5-tabcontainer>
104104

105105
<h5>Icons only</h5>
106-
<ui5-tabcontainer show-overflow="true" selected-index="1">
106+
<ui5-tabcontainer show-overflow="true" selected-index="1" id="tabContainerIconOnly">
107107
<ui5-tab key="item1" icon="sap-icon://employee" count="12343455">
108108
<ui5-button>Button 11</ui5-button>
109109
<ui5-button>Button 12</ui5-button>
@@ -117,14 +117,15 @@ <h5>Icons only</h5>
117117

118118

119119
<h5>Text Only</h5>
120-
<ui5-tabcontainer show-overflow="true" selected-index="3">
120+
<ui5-tabcontainer show-overflow="true" id="tabContainerTextOnly">
121121
<ui5-tab key="item1" text="Tab 1">
122122
<ui5-button>Button 11</ui5-button>
123123
<ui5-button>Button 12</ui5-button>
124124
</ui5-tab>
125125
<ui5-tab key="item2" text="Tab 2">
126+
<ui5-button>Button 2</ui5-button>
126127
</ui5-tab>
127-
<ui5-tab key="item3" text="Tab 2">
128+
<ui5-tab key="item3" text="Tab 3">
128129
<ui5-button>Button 3</ui5-button>
129130
</ui5-tab>
130131
</ui5-tabcontainer>
@@ -173,4 +174,4 @@ <h5>Text and Count Inline Mode</h5>
173174
});
174175
</script>
175176
</body>
176-
</html>
177+
</html>

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

+46-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,49 @@ describe("TabContainer general interaction", () => {
1818
assert.strictEqual(field2.getProperty("value"), SELECTED_TAB_KEY, "Item data-key is retrieved correctly");
1919
assert.strictEqual(field3.getProperty("value"), SELECTED_TAB_TEXT, "Item text is retrieved correctly.");
2020
});
21-
});
21+
22+
it("scroll works on iconsOnly TabContainer", () => {
23+
browser.setWindowSize(250, 1080);
24+
25+
const arrowLeft = browser.findElementDeep("#tabContainerIconOnly >>> .sapMITBArrowScrollLeft");
26+
const arrowRight = browser.findElementDeep("#tabContainerIconOnly >>> .sapMITBArrowScrollRight");
27+
28+
assert.ok(!arrowLeft.isDisplayed(), "'Left Arrow' should be initially hidden");
29+
assert.ok(arrowRight.isDisplayed(), "'Right Arrow' should be initially shown");
30+
31+
arrowRight.click();
32+
browser.pause(300); // TODO: wait for animation finish. Remove when solved on framework level
33+
34+
assert.ok(arrowLeft.isDisplayed(), "'Left Arrow' should be shown after 'Right Arrow' click");
35+
assert.ok(!arrowRight.isDisplayed(), "'Right Arrow' should be hidden after 'Right Arrow' click");
36+
37+
arrowLeft.click();
38+
browser.pause(300); // TODO: wait for animation finish. Remove when solved on framework level
39+
40+
assert.ok(!arrowLeft.isDisplayed(), "'Left Arrow' should be hidden after 'Left Arrow' click");
41+
assert.ok(arrowRight.isDisplayed(), "'Right Arrow' should be shown after 'Left Arrow' click");
42+
});
43+
44+
it("scroll works on textOnly TabContainer", () => {
45+
browser.setWindowSize(250, 1080);
46+
browser.findElementDeep("#tabContainerTextOnly").scrollIntoView();
47+
48+
const arrowLeft = browser.findElementDeep("#tabContainerTextOnly >>> .sapMITBArrowScrollLeftTextOnly");
49+
const arrowRight = browser.findElementDeep("#tabContainerTextOnly >>> .sapMITBArrowScrollRightTextOnly");
50+
51+
assert.ok(!arrowLeft.isDisplayed(), "'Left Arrow' should be initially hidden");
52+
assert.ok(arrowRight.isDisplayed(), "'Right Arrow' should be initially shown");
53+
54+
arrowRight.click();
55+
browser.pause(300); // TODO: wait for animation finish. Remove when solved on framework level
56+
57+
assert.ok(arrowLeft.isDisplayed(), "'Left Arrow' should be shown after 'Right Arrow' click");
58+
assert.ok(!arrowRight.isDisplayed(), "'Right Arrow' should be hidden after 'Right Arrow' click");
59+
60+
arrowLeft.click();
61+
browser.pause(300); // TODO: wait for animation finish. Remove when solved on framework level
62+
63+
assert.ok(!arrowLeft.isDisplayed(), "'Left Arrow' should be hidden after 'Left Arrow' click");
64+
assert.ok(arrowRight.isDisplayed(), "'Right Arrow' should be shown after 'Left Arrow' click");
65+
});
66+
});

0 commit comments

Comments
 (0)