-
Notifications
You must be signed in to change notification settings - Fork 312
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]: cds-combo-box Component Fails to Refresh with Lazy Loaded Options in Reactive Form #2961
Comments
Hi @danielsogl, Seems like the two components are getting out of sync, you can trigger change detection manually to fix this. You can do this by injecting The view can be refreshed after step 3 and it should show the value selected. |
Hi, sadly this won't help. I already tried fixing it by calling the change detection manually. The combo box remains displayed as empty/unselected. |
Any chance you can create a stackblitz demo to help us reproduce this? I'm currently testing in storybook and using |
@Akshat55 looks like the stackblitz template is broken so I created a demo project to reproduce the issue. The combobox won't show the selected item with the id 1 after the list items are set lazy when pressing the button. It will only work, if you are patching the form again and setting the selected value again: https://github.com/danielsogl/carbon-design-combobox-bug |
@Akshat55 an update from my side. Looks like the issue is that the |
@danielsogl Apologies for the late response, I got side tracked. I took a look your code and it seems the current behavior is not supported in the combobox... And probably won't be, unless we do a breaking change. As of now, the expected behavior is the itemsList is initialized before the value is set. In your scenario, the value is set, but the items list is empty so we can't set You can continue to initialize the form item before the combobox list is set, however you will need to iterate through the combobox items list and set |
Detailed description
I’m encountering an issue with the cds-combo-box component when used in a reactive form. Specifically, the problem arises when the available options for the combo box are loaded asynchronously from the backend. Even though the form is patched correctly, the combo box does not refresh to display the selected value once the options are set. Instead, it shows an empty value, which leads to a poor user experience.
Steps to reproduce the issue
The text was updated successfully, but these errors were encountered: