Skip to content

fix: tab: added a prop to enable standard key navigation for tabs component #953

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

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

mbhagat-c-eightfold
Copy link
Contributor

@mbhagat-c-eightfold mbhagat-c-eightfold commented Feb 26, 2025

SUMMARY:

Problem: No std key navigation for the tabs
Solution:

  • Added a prop to enable standard W3C Tabs navigation(so that there is no regression).
  • Added keydown events to enable navigation through arrow keys.

GITHUB ISSUE (Open Source Contributors)

NA

JIRA TASK (Eightfold Employees Only):

https://eightfoldai.atlassian.net/browse/ENG-123289
https://eightfoldai.atlassian.net/browse/ENG-127383
https://eightfoldai.atlassian.net/browse/ENG-125640

CHANGE TYPE:

  • Bugfix Pull Request
  • Feature Pull Request

TEST COVERAGE:

  • Tests for this change already exist
  • I have added unittests for this change

TEST PLAN:

CASE: if enableArrowNav is enabled then standard arrow key navigation is activated, wherein navigation through the tabs is possible by arrow keys and on enter the focus should go to the selected tab.

  • pull branch down locally and start storybook (yarn storybook).
  • Navigate to the tabs component, and enable enableArrowNav in the Controls.
  • Verify if navigation to different tabs is achieved with arrow keys, on click enter the tab is selected.

Note: If any focusable element is present inside the tab panel then on tabbing after selection of the tab, the focus should go to the focusable element else move outside the tab component.

i. enableArrowNav is disabled.

tabsNormalN.mp4

ii. enableArrowNav is enabled.

tabsArrowN.1.mp4

Steps for Regression:
i. Verify that the tab is working as expected with and without enabling enableArrowNav prop

Copy link

codesandbox-ci bot commented Feb 26, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@mbhagat-c-eightfold mbhagat-c-eightfold self-assigned this Feb 27, 2025
@ypatadia-eightfold ypatadia-eightfold self-requested a review March 5, 2025 00:55
Copy link
Collaborator

@ypatadia-eightfold ypatadia-eightfold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code that is written to solve the issue was imperative where we directly manipulated the DOM. Can you please try out the changes I've commented locally and see if the functionality is working as expected. The code I've given follows the declarative paradigm of react.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@mbhagat-c-eightfold mbhagat-c-eightfold changed the title fix: tab: added a prop to enable standard key navigation for tabs com… fix: tab: added a prop to enable standard key navigation for tabs component May 25, 2025

This comment has been minimized.

Copy link
Collaborator

@ypatadia-eightfold ypatadia-eightfold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. rebase with master, and test the PR again if it's working
  2. write unit tests for these changes

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link

codecov bot commented Jun 16, 2025

Codecov Report

Attention: Patch coverage is 34.69388% with 96 lines in your changes missing coverage. Please review.

Project coverage is 84.08%. Comparing base (6dc4250) to head (9dc9dfc).

Files with missing lines Patch % Lines
src/components/Tabs/Tabs.context.tsx 22.68% 92 Missing ⚠️
src/components/Tabs/Tab/Tab.tsx 82.35% 3 Missing ⚠️
src/components/Tabs/Tabs/AnimatedTabs.tsx 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #953      +/-   ##
==========================================
- Coverage   84.43%   84.08%   -0.35%     
==========================================
  Files        1104     1104              
  Lines       20654    20798     +144     
  Branches     7822     7881      +59     
==========================================
+ Hits        17440    17489      +49     
- Misses       3126     3221      +95     
  Partials       88       88              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants