-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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]: Carbon ComboBox does not reset displayed "selectedItem" value after setting to null #17192
Comments
+1, we are encountering the same bug. |
Following the issue, because we've also encountered the same problem. |
+1 |
Facing same issue. Applying above workaround, it seems to work from external actions but when we click on cross(clear) icon provided by combobox, it does not reset the value. |
+1 |
Package
@carbon/react
Browser
Firefox
Package version
@carbon/react: 1.60.3
React version
react: 18.2.0
Description
I am using a
ComboBox
populated with values from my store. After the user submits the value selected in the combo box, I update the selectedItem to "null", which is also derived from my store. The displayed value in the combo box does not reset and retains the last selected item, even after resetting the selectedItem to "null" in the store.A workaround for this issue is to use
useRef
for the key of the of combo box, anduseEffect
to update thecurrent
value of the key any time the selectedItem changes. This will force a re-render of the combo box, resetting its value. Example of workaround:Reproduction/example
https://stackblitz.com/edit/github-wkihg5?file=src%2FApp.jsx
Steps to reproduce
Reproduction example provided in link above. Have
selectedItem
derived from state and some mechanism that resetsselectedItems
after user action. Combo box will not reset its displayed item, even afterselectedItem
is set to null.Suggested Severity
Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.
Application/PAL
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: