Skip to content

Commit da27ed5

Browse files
authored
fix(ui5-tabcontainer): correct focus handling in overflow modes (#12259)
fixes: #12027
1 parent 2fb71a7 commit da27ed5

File tree

2 files changed

+96
-2
lines changed

2 files changed

+96
-2
lines changed

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

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,102 @@ describe("TabContainer keyboard handling", () => {
11441144
cy.get("@tabContainer").shadow().find("ui5-responsive-popover").as("popover");
11451145
cy.get("@popover").should("be.visible", "Popover is opened");
11461146
});
1147+
1148+
it("tests handling of the focus navigation with End overflow mode", () => {
1149+
cy.mount(
1150+
<>
1151+
<Button id="btn1"/>
1152+
<TabContainer id="tabContainerStartAndEndOverflow" overflowMode="End">
1153+
<Tab text="One">Tab 1</Tab>
1154+
<Tab text="Two">Tab 2</Tab>
1155+
<Tab id="activeTab" text="Three" selected>Tab 3</Tab>
1156+
<Tab text="Four">Tab 4</Tab>
1157+
<Tab text="Five">Tab 4</Tab>
1158+
</TabContainer>
1159+
<Button id="btn2"/>
1160+
</>
1161+
);
1162+
1163+
cy.viewport(300, 1080);
1164+
1165+
cy.get("#tabContainerStartAndEndOverflow").shadow().find(".ui5-tc__overflow--end").as("endOverflow");
1166+
1167+
cy.get("#btn1").realClick();
1168+
1169+
cy.realPress("Tab");
1170+
1171+
cy.realPress("ArrowRight");
1172+
1173+
cy.get("@endOverflow")
1174+
.find("[ui5-button]")
1175+
.shadow()
1176+
.find(".ui5-button-root")
1177+
.should("be.focus");
1178+
1179+
cy.realPress("Tab");
1180+
1181+
cy.get("#btn2").should("be.focused");
1182+
1183+
cy.realPress(["Shift", "Tab"]);
1184+
1185+
cy.get("@endOverflow")
1186+
.find("[ui5-button]")
1187+
.shadow()
1188+
.find(".ui5-button-root")
1189+
.should("be.focus");
1190+
1191+
cy.realPress(["Shift", "Tab"]);
1192+
1193+
cy.get("#btn1").should("be.focused");
1194+
});
1195+
1196+
it("tests handling of the focus navigation with Start overflow mode", () => {
1197+
cy.mount(
1198+
<>
1199+
<Button id="btn1"/>
1200+
<TabContainer id="tabContainerStartAndEndOverflow" overflowMode="StartAndEnd">
1201+
<Tab text="One">Tab 1</Tab>
1202+
<Tab text="Two">Tab 2</Tab>
1203+
<Tab id="activeTab" text="Three" selected>Tab 3</Tab>
1204+
<Tab text="Four">Tab 4</Tab>
1205+
<Tab text="Five">Tab 4</Tab>
1206+
</TabContainer>
1207+
<Button id="btn2"/>
1208+
</>
1209+
);
1210+
1211+
cy.viewport(300, 1080);
1212+
1213+
cy.get("#tabContainerStartAndEndOverflow").shadow().find(".ui5-tc__overflow--start").as("startOverflow");
1214+
1215+
cy.get("#btn1").realClick();
1216+
1217+
cy.realPress("Tab");
1218+
1219+
cy.realPress("ArrowLeft");
1220+
1221+
cy.get("@startOverflow")
1222+
.find("[ui5-button]")
1223+
.shadow()
1224+
.find(".ui5-button-root")
1225+
.should("be.focus");
1226+
1227+
cy.realPress("Tab");
1228+
1229+
cy.get("#btn2").should("be.focused");
1230+
1231+
cy.realPress(["Shift", "Tab"]);
1232+
1233+
cy.get("@startOverflow")
1234+
.find("[ui5-button]")
1235+
.shadow()
1236+
.find(".ui5-button-root")
1237+
.should("be.focus");
1238+
1239+
cy.realPress(["Shift", "Tab"]);
1240+
1241+
cy.get("#btn1").should("be.focused");
1242+
});
11471243
});
11481244

11491245
describe("TabContainer popover", () => {

packages/main/src/TabContainerTemplate.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export default function TabContainerTemplate(this: TabContainer, injectedPartial
7373
<Button
7474
endIcon={this.overflowMenuIcon}
7575
data-ui5-stable="overflow-start"
76-
tabindex={ -1 }
7776
tooltip={this.overflowMenuTitle}
7877
accessibilityAttributes={this.overflowBtnAccessibilityAttributes}
7978
>
@@ -108,7 +107,6 @@ export default function TabContainerTemplate(this: TabContainer, injectedPartial
108107
<Button
109108
endIcon={this.overflowMenuIcon}
110109
data-ui5-stable="overflow-end"
111-
tabindex={ -1 }
112110
tooltip={this.overflowMenuTitle}
113111
accessibilityAttributes={this.overflowBtnAccessibilityAttributes}
114112
>

0 commit comments

Comments
 (0)