Skip to content

fix(ui5-side-navigation): right arrow and left arrow behavior fixed #11434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 16, 2025
264 changes: 264 additions & 0 deletions packages/fiori/cypress/specs/SideNavigation.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import group from "@ui5/webcomponents-icons/dist/group.js";
import { NAVIGATION_MENU_POPOVER_HIDDEN_TEXT } from "../../src/generated/i18n/i18n-defaults.js";
import Title from "@ui5/webcomponents/dist/Title.js";
import Label from "@ui5/webcomponents/dist/Label.js";
import ResponsivePopover from "@ui5/webcomponents/dist/ResponsivePopover.js";

describe("Side Navigation Rendering", () => {
it("Tests rendering in collapsed mode", () => {
Expand Down Expand Up @@ -222,6 +223,269 @@ describe("Side Navigation interaction", () => {
cy.get("#unselectableItem").should("be.focused").and("not.have.attr", "expanded");
});

it("Tests expanding of items with ArrowRight", () => {
cy.mount(
<SideNavigation id="sn">
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
);

cy.get("#focusStart").realClick();
cy.realPress("ArrowDown");
cy.realPress("ArrowRight");

cy.get("#unselectableItem").should("have.attr", "expanded");
});

it("Tests collapsing of items with ArrowLeft", () => {
cy.mount(
<SideNavigation id="sn">
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1" expanded>
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
);
cy.get("#focusStart").realClick();
cy.realPress("ArrowDown");
cy.realPress("ArrowLeft");

cy.get("#unselectableItem").should("not.have.attr", "expanded");

});

it("Tests expanding of items with ArrowRight on collapsed sn", () => {
cy.mount(
<SideNavigation id="sn" collapsed={true}>
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem id="snn1" text="1.2" />
</SideNavigationItem>
</SideNavigation>
);

cy.get("#unselectableItem").realClick();

cy.get("#sn")
.shadow()
.find(`[ui5-side-navigation-item][text="1"]`)
.should('be.focused');

cy.realPress("ArrowLeft");
cy.get("#unselectableItem").should('be.focused');

cy.realPress("ArrowRight");
cy.get("#sn")
.shadow()
.find(`[ui5-side-navigation-item][text="1"]`)
.should('be.focused');

cy.get("#sn")
.shadow()
.find<ResponsivePopover>("[ui5-responsive-popover]")
.ui5ResponsivePopoverOpened();
});

it("Tests collapsing of items with ArrowLeft on collapsed sn", () => {
cy.mount(
<SideNavigation id="sn" collapsed={true}>
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
);

cy.get("#unselectableItem").realClick();

cy.get("#sn")
.shadow()
.find(`[ui5-side-navigation-item][text="1"]`)
.should('be.focused'); // Фокуса на правилното място ли е след, като съм отворил popover?

cy.realPress("ArrowLeft"); // Ако фокуса е на правилното място, натисни ArrowLeft

cy.get("#unselectableItem").should('be.focused'); // След като съм натиснал ArrowLeft, провери дали фокуса е на правилното място

cy.get("#sn")
.shadow()
.find<ResponsivePopover>("[ui5-responsive-popover]")
.ui5ResponsivePopoverClosed(); // Ако фокуса е на правилното място провери дали popover-a е затворен, защото така очаквам
});

it("Tests expanding of items with ArrowLeft for rtl", () => {
cy.mount(
<div dir="rtl">
<SideNavigation id="sn">
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
</div>
);

cy.get("#focusStart").realClick();
cy.realPress("ArrowDown");
cy.realPress("ArrowLeft");

cy.get("#unselectableItem").should("have.attr", "expanded");
});

it("Tests collapsing of items with ArrowRight for rtl", () => {
cy.mount(
<div dir="rtl">
<SideNavigation id="sn">
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
</div>
);

cy.get("#unselectableItem").realClick();
cy.get("#unselectableItem").realPress("ArrowRight");

cy.get("#unselectableItem").should("not.have.attr", "expanded");

});

it("Tests expanding of items with ArrowLeft on collapsed sn for rtl", () => {
cy.mount(
<div dir="rtl">
<SideNavigation id="sn" collapsed={true}>
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
</div>
);

cy.get("#unselectableItem").realClick();

cy.get("#sn")
.shadow()
.find(`[ui5-side-navigation-item][text="1"]`)
.should('be.focused');

cy.realPress("ArrowRight");

cy.get("#unselectableItem").should('be.focused');

cy.realPress("ArrowLeft");
cy.get("#sn")
.shadow()
.find(`[ui5-side-navigation-item][text="1"]`)
.should('be.focused');

cy.get("#sn")
.shadow()
.find<ResponsivePopover>("[ui5-responsive-popover]")
.ui5ResponsivePopoverOpened();
});

it("Tests collapsing of items with ArrowRight on collapsed sn for rtl", () => {
cy.mount(
<div dir="rtl">
<SideNavigation id="sn" collapsed={true}>
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
</div>
);

cy.get("#unselectableItem").realClick();
cy.get("#sn")
.shadow()
.find(`[ui5-side-navigation-item][text="1"]`)
.should('be.focused');

cy.realPress("ArrowRight");

cy.get("#sn")
.shadow()
.find<ResponsivePopover>("[ui5-responsive-popover]")
.ui5ResponsivePopoverClosed();
});

it("Tests expanding of items with Plus", () => {
cy.mount(
<SideNavigation id="sn">
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
);

cy.get("#focusStart").realClick();
cy.realPress("ArrowDown");
cy.realPress("+");

cy.get("#unselectableItem").should("have.attr", "expanded");

});

it("Tests collapsing of items with Minus", () => {
cy.mount(
<SideNavigation id="sn">
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
);

cy.get("#unselectableItem").realClick();
cy.realPress("-");

cy.get("#unselectableItem").should("not.have.attr", "expanded");

});

it("Tests expanding of items with Plus for rtl", () => {
cy.mount(
<div dir="rtl">
<SideNavigation id="sn">
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
</div>
);

cy.get("#focusStart").realClick();
cy.realPress("ArrowDown");
cy.realPress("+");

cy.get("#unselectableItem").should("have.attr", "expanded");
});

it("Tests collapsing of items with Minus for rtl", () => {
cy.mount(
<div dir="rtl">
<SideNavigation id="sn">
<SideNavigationItem id="focusStart" text="focus start"></SideNavigationItem>
<SideNavigationItem id="unselectableItem" text="1">
<SideNavigationSubItem text="1.2" />
</SideNavigationItem>
</SideNavigation>
</div>
);
cy.get("#unselectableItem").realClick();
cy.realPress("-");

cy.get("#unselectableItem").should("not.have.attr", "expanded");
});

it("Tests expanding and collapsing of unselectable parent item when SideNavigation is collapsed", () => {
cy.mount(
<SideNavigation id="sideNav" collapsed={true}>
Expand Down
Loading
Loading