ComboBox onClick does not trigger with null selectedItem when items is objects
See original GitHub issueWhat package(s) are you using?
-
carbon-components
-
carbon-components-react
Detailed description
Describe in detail the issue you’re having.
I have noticed that, when passing in an array of objects into the ComboBox’s items
prop, that when the selectedItem
prop is set to null, the onClick
event handler is not called when you click the clear button. Any other case, that event handler is called when selecting an item from the drop down or clicking the clear filter/button in the search field except when that prop has null passed inside. I found this out when I used null to reset it.
Is this issue related to a specific component?
ComboBox
What did you expect to happen? What happened instead? What would you like to
I learned that resetting the value to appear within the combobox by default via selectedItem
works when passing in an empty object, but it took me a while to figure this out due to thinking null should work fine. So I would expect null to work the same as an empty object.
Steps to reproduce the issue
I set up a sandbox with different scenarios commented out
https://codesandbox.io/s/optimistic-bas-6ovuo?file=/src/index.js
Additional information
This may not even be a bug, or if it is a very low one, but if it is not a bug, then it should be made aware the behavior differences between passing in null vs an object (or empty object in this case)
thank you!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Hey, I won’t lie, it’s been a while since I looked at this I forgot my logic in the issue, however, looking at my comments in the sandbox, i no longer see the issue as described in the comments and noticed the sandbox is set to use the latest carbon react components.
With the fact I dont remember the exact details, i can’t recreate it in the latest version as per described in the comments, and it was avery specific situations, I think it is safe to say we could probably close this
Hey @TannerS I think I’m understanding the issue. I have a few questions: