Skip to content
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

feat(tabs): traverse tabs with arrow keys #8116

Prev Previous commit
Next Next commit
chore(tabs): update a11y cypress test
  • Loading branch information
weronikaolejniczak committed Nov 21, 2024
commit 2075b019035424da7ce3a230c0b04887741628ab
13 changes: 11 additions & 2 deletions packages/eui/src/components/tabs/tabs.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,22 @@ describe('EuiTabs', () => {
it('handles keypress events', () => {
cy.realMount(<TabbedContent />);
cy.realPress('Tab');
cy.realPress(['Shift', 'Tab']);
cy.realPress('ArrowLeft');
// on enter, should select the first tab
cy.realPress('Enter');
cy.get('div[role="tabpanel"]').first().should('exist');
cy.get('div[role="tabpanel"]').should('have.length', 1);
cy.focused().should('have.text', 'Cobalt');
cy.repeatRealPress('Tab', 3);
// on arrow right, should navigate to the next tab
cy.repeatRealPress('ArrowRight', 3);
cy.focused().should('have.text', 'Monosodium Glutamate');
// on arrow right, should loop back to the first tab
cy.repeatRealPress('ArrowRight', 1);
cy.focused().should('have.text', 'Cobalt');
// on arrow left, should loop back to the last tab
cy.repeatRealPress('ArrowLeft', 1);
cy.focused().should('have.text', 'Monosodium Glutamate');
// on enter, should select the last tab
cy.realPress('Enter');
cy.get('div[role="tabpanel"]').last().should('exist');
cy.get('div[role="tabpanel"]').should('have.length', 1);
Expand Down