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

[Bug]: ComboBox: onChange is called twice when clearing the input field #18137

Open
2 tasks done
pedesen opened this issue Nov 21, 2024 · 0 comments
Open
2 tasks done

Comments

@pedesen
Copy link

pedesen commented Nov 21, 2024

Package

@carbon/react

Browser

Firefox, Chrome

Package version

1.70.0

React version

18.2.0

Description

There is another issue when ComboBox is used as a fully controlled input (meaning with selectedItem and onChange props provided):

When clicking on the "clear selected item" button, the onChange is called twice: first time with null and second time with the item that was cleared before. This leads to unexpected behavior.

This currently prevents us to upgrade @carbon/react, because I was not able to find a workaround for this.

Reproduction/example

https://stackblitz.com/edit/github-w7mkre-dtgf2u?file=src%2FApp.jsx

Steps to reproduce

  1. Clear combobox
  2. Select Item 1
  3. Clear combobox again
  4. Observe console logs

Problem: After step 3 onChange is called twice: first time with null and second time with the item that was cleared before. This leads to unexpected behavior.

Suggested Severity

Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.

Application/PAL

No response

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant