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

WIP | fix: stopped combobox's onChange throwing undefined when selected item is clicked again and fixed keyboard interaction #18387

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Gururajj77
Copy link
Contributor

@Gururajj77 Gururajj77 commented Jan 21, 2025

Closes #18286
Closes #18386

18226 issue: stops the onChange handler from firing with undefined when the same item is clicked. Now it does not fire onChange handler when the selected item is clicked again.

Second: The keyboard interaction would fire 2 onChange handlers, one with previously selected value and one with the new selected value.

Changelog

Changed

  • modified the onStateChange to include a check for being undefined:
    newSelectedItem !== undefined

Removed

  • if (allowCustomValue && isOpen && inputValue) {
    onChange({ selectedItem, inputValue });
    }

Removed this condition as this was firing the onChange with previous selected value when the combobox is interacted with keyboard

Testing / Reviewing

  • Open the test story
  • keep the console open
  • select item '2' by using keyboard
  • see that console has a log:
    Parent onChange called with: 2

@Gururajj77 Gururajj77 marked this pull request as ready for review January 21, 2025 14:15
@Gururajj77 Gururajj77 requested a review from a team as a code owner January 21, 2025 14:15
Copy link

netlify bot commented Jan 21, 2025

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

Name Link
🔨 Latest commit dd38914
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/678faac4b514e40008a1dd6f
😎 Deploy Preview https://deploy-preview-18387--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 21, 2025

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit dd38914
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/678faac414e53c0008cbe664
😎 Deploy Preview https://deploy-preview-18387--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 21, 2025

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit dd38914
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/678faac459a47300094b7aaa
😎 Deploy Preview https://deploy-preview-18387--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.

@Gururajj77 Gururajj77 changed the title fix: stopped combobox's onChange throwing undefined when selected item is clicked again and fixed keyboard interaction WIP | fix: stopped combobox's onChange throwing undefined when selected item is clicked again and fixed keyboard interaction Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant