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 downshiftProps after selecting a item is not emitting onChange event #18212

Open
2 tasks done
ashishkrz opened this issue Dec 9, 2024 · 5 comments · May be fixed by #18441
Open
2 tasks done

[Bug]: ComboBox downshiftProps after selecting a item is not emitting onChange event #18212

ashishkrz opened this issue Dec 9, 2024 · 5 comments · May be fixed by #18441
Labels

Comments

@ashishkrz
Copy link

Package

@carbon/react

Browser

Chrome

Package version

1.72.0

React version

18.3.1

Description

There was an issue with Combobox with downshiftProps, which got fixed here #17027. But now the issue is , after the item gets selected from combobox, the onChange event is not happening.

Reproduction/example

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

Steps to reproduce

Try selecting item from combobox, observe the onChange is not getting called after a selection:

onChange={(e) => { console.info('HELLO', e); }}

Suggested Severity

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

Application/PAL

Power Virtual Server UI (PowerVS)

Code of Conduct

@2nikhiltom
Copy link
Contributor

Hey, do you see this issue on 1.72.0?, the stackblitz you shared is on 1.71.1

@ashishkrz
Copy link
Author

ashishkrz commented Dec 11, 2024

@2nikhiltom I updated the package there, please check. The issue exist on 1.72.0.

@ashishkrz ashishkrz changed the title [Bug]: ComboBox downshiftProps after selecting a item is not emit onChange event [Bug]: ComboBox downshiftProps after selecting a item is not emitting onChange event Dec 11, 2024
@2nikhiltom 2nikhiltom moved this from 🕵️‍♀️ Triage to ⏱ Backlog in Design System Dec 12, 2024
@ashishkrz
Copy link
Author

@2nikhiltom Do we have any update on same?

@cknabe
Copy link
Contributor

cknabe commented Jan 24, 2025

@Neues I think this is related to your change here: #18041

Passing in onStateChange in downshiftProps is overriding the onStateChange passed into useCombobox. The reason this breaks, is because onChange was moved from onInputValueChange and onSelectedItemChange into the new onStateChange.

I reverted the changes in 18041 locally and everything works as expected.

Without digging further into it, I guess there are a number of possibilities:

  1. @ashishkrz or anyone else overriding onStateChange, can call onChange in their overriden code
  2. A solution could be found where onChange is called outside of onStateChange
  3. Revert 18041 and find a different solution for that issue

@Neues Neues linked a pull request Jan 27, 2025 that will close this issue
@Neues
Copy link
Contributor

Neues commented Jan 27, 2025

@cknabe Thanks for the tag and the detailed description of the issue. The solution that I came up with is to call downshiftProps.onStateChange within the existing onStateChange so that the onChange continues to work as expected. Let me know what you think.
#18441

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

Successfully merging a pull request may close this issue.

5 participants