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: stopped onChange throwing undefined #18452

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

Conversation

Gururajj77
Copy link
Contributor

Closes #18286
Closes #18361

This PR resolves two things:

  • stops onChange from getting called again when an already selected item is selected again.
  • stops onChange from throwing undefined.

Changelog

Changed

  • added the line !isEqual(selectedItemProp, newSelectedItem) to the keyboard event handler inside the onStateChange to make sure we don't call the onChange even when we select the same item.

Testing / Reviewing

  • Go to the "On Change Test" story.
  • open the console.
  • select an item
  • there should be log with the selected item
  • try to select the same item
  • we should not see the same item getting logged again.
  • try this using both keyboard and mouse

Copy link

netlify bot commented Jan 28, 2025

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit 81eeaa0
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/67988995d0c6bd0008c8a640
😎 Deploy Preview https://deploy-preview-18452--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 Jan 28, 2025

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

Name Link
🔨 Latest commit 5970c16
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/6798e5bdc43e860008ca057d
😎 Deploy Preview https://deploy-preview-18452--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 Jan 28, 2025

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 5970c16
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/6798e5bcd9a6720008451ded
😎 Deploy Preview https://deploy-preview-18452--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 Jan 28, 2025

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit 5970c16
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/6798e5bc998f76000893ca7f
😎 Deploy Preview https://deploy-preview-18452--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 Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.16%. Comparing base (5a0348c) to head (5970c16).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18452   +/-   ##
=======================================
  Coverage   84.16%   84.16%           
=======================================
  Files         408      408           
  Lines       14449    14450    +1     
  Branches     4696     4647   -49     
=======================================
+ Hits        12161    12162    +1     
  Misses       2124     2124           
  Partials      164      164           

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

@Gururajj77 Gururajj77 marked this pull request as ready for review January 28, 2025 13:58
@Gururajj77 Gururajj77 requested a review from a team as a code owner January 28, 2025 13:58
Copy link
Member

@emyarod emyarod 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 to me!

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