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

fix: adds arrow keys navigation functionality in the Switcher, and increases test coverage #18115

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

Conversation

2nikhiltom
Copy link
Contributor

@2nikhiltom 2nikhiltom commented Nov 19, 2024

Closes #17493

This PR addresses an issue where the Arrow keys navigation functionality in the Switcher component was no longer working after types were added and Increases the test coverage to 100%

The cause for navigation issues was related to a change in the condition for checking the component type

child.type?.displayName === 'SwitcherItem' condition in earlier .js file was changed to getDisplayName(child.type) === 'Switcher' when component was converted to .tsx

Changelog

New

  • added getDisplayName(curr.type) === 'SwitcherItem' check in enabledIndices to ensures that only SwitcherItem components are included in the navigation
  • added conditions to handle edge cases in nextValidIndex function
  • added Test to cover the Arrow key and Tab key navigation behavior

Changed

reverted to getDisplayName(child.type) === 'SwitcherItem'

Testing / Reviewing

  1. Open deploy preview and go to switcher component usage in storybook
  2. image
  3. open the panel and navigate the links via both Tab and Arrow keys
  4. Verify the test coverage is 100%

Copy link

netlify bot commented Nov 19, 2024

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 12ffca3
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/67440e49a2c3e30008ce0358
😎 Deploy Preview https://deploy-preview-18115--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 19, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 12ffca3
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/67440e492d27200008fe9249
😎 Deploy Preview https://deploy-preview-18115--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 19, 2024

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit d02c95e
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/673ccfb976843e0009c70f33
😎 Deploy Preview https://deploy-preview-18115--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 19, 2024

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit 12ffca3
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/67440e497369db0008c77c45
😎 Deploy Preview https://deploy-preview-18115--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.01%. Comparing base (626289a) to head (12ffca3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18115      +/-   ##
==========================================
+ Coverage   82.87%   83.01%   +0.13%     
==========================================
  Files         404      404              
  Lines       14338    14344       +6     
  Branches     4591     4616      +25     
==========================================
+ Hits        11882    11907      +25     
+ Misses       2296     2276      -20     
- Partials      160      161       +1     

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


🚨 Try these New Features:

@2nikhiltom 2nikhiltom changed the title test: test coverage for switcher fix: adds arrow keys navigation functionality in the Switcher, and increases test coverage Nov 21, 2024
@2nikhiltom 2nikhiltom marked this pull request as ready for review November 21, 2024 12:31
@2nikhiltom 2nikhiltom requested a review from a team as a code owner November 21, 2024 12:31
Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀
Thanks for adding the arrow navigation

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

Successfully merging this pull request may close these issues.

Increase Switcher unit test coverage
2 participants