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

Merged
merged 9 commits into from
Nov 26, 2024

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 9c306fd
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/6745ab1bbea4ef0008e7b057
😎 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 9c306fd
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/6745ab1b44923d000809be9a
😎 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 9c306fd
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/6745ab1b1afb810008cfc241
😎 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.36%. Comparing base (f2ba3fd) to head (9c306fd).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18115      +/-   ##
==========================================
+ Coverage   83.22%   83.36%   +0.13%     
==========================================
  Files         404      404              
  Lines       14338    14344       +6     
  Branches     4645     4646       +1     
==========================================
+ Hits        11933    11958      +25     
+ Misses       2243     2224      -19     
  Partials      162      162              

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

@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

Copy link
Contributor

@Gururajj77 Gururajj77 left a comment

Choose a reason for hiding this comment

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

Looks Good!

Copy link
Member

@alisonjoseph alisonjoseph 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!

@alisonjoseph alisonjoseph added this pull request to the merge queue Nov 26, 2024
Merged via the queue into main with commit 0da5e37 Nov 26, 2024
40 checks passed
@alisonjoseph alisonjoseph deleted the test-coverage-for-switcher branch November 26, 2024 14:05
Copy link
Contributor

The content of this pull request will be made available as part of our next release. For the full schedule of upcoming releases, check out our Release Radar page.

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
4 participants