[Bug]: FilterableMutiselect "onMenuChange" triggering multiple times on render #18270
Open
2 tasks done
Labels
component: filterable-multiselect
role: dev 🤖
severity: 3
https://ibm.biz/carbon-severity
type: bug 🐛
Package
@carbon/react
Browser
Chrome
Package version
1.72
React version
18.3
Description
After @carbon/react v1.65, onMenuChange started triggering multiple times on the first render. I have a state update that is based on the onMenuChage callback which is now causing my application to have an odd behavior.
Also, now I need to use a useCallback so the application doesn't start looping and crashes. This is also reproducible by just removing the useCallback from the function passed to onMenuChange.
I tracked it down to this bug fix: #16896
Previous behavior the onMenuChange callback was only triggered after the user interacted with the dropdown.
Reproduction/example
https://stackblitz.com/edit/github-ehxczfmb?file=src%2FApp.tsx
Steps to reproduce
expected result: count should only be updated after the menu open/closes
actual result: count state is updated after render
Downgrading @carbon/react to v1.65 will make it work as expected.
Suggested Severity
Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.
Application/PAL
RPA
Code of Conduct
The text was updated successfully, but these errors were encountered: