Skip to content

fix(Dropdown,Combobox): fixed selection lost updating ListItems when using reactive forms or ngModel#3377

Open
Licen-it wants to merge 11 commits into
carbon-design-system:masterfrom
Licen-it:issue#3376
Open

fix(Dropdown,Combobox): fixed selection lost updating ListItems when using reactive forms or ngModel#3377
Licen-it wants to merge 11 commits into
carbon-design-system:masterfrom
Licen-it:issue#3376

Conversation

@Licen-it

@Licen-it Licen-it commented May 20, 2026

Copy link
Copy Markdown
Contributor

Closes #3376
Closes #3389

Fixed the selection lost when updating the ListItems

Changelog

Changed

  • the selection is restored if the selected items still match items in the option list and the new list doesn't have any selected item already

@Licen-it Licen-it requested a review from a team as a code owner May 20, 2026 01:23
@netlify

netlify Bot commented May 20, 2026

Copy link
Copy Markdown

Deploy Preview for carbon-components-angular ready!

Name Link
🔨 Latest commit d252acc
🔍 Latest deploy log https://app.netlify.com/projects/carbon-components-angular/deploys/6a3e446729f99f0008d42514
😎 Deploy Preview https://deploy-preview-3377--carbon-components-angular.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@Licen-it Licen-it changed the title fix(DropdownList): fixed selection lost updating ListItems @Licen-it fix(Dropdown,Combobox): fixed selection lost updating ListItems when using reactive forms or ngModel May 22, 2026
@Licen-it Licen-it changed the title @Licen-it fix(Dropdown,Combobox): fixed selection lost updating ListItems when using reactive forms or ngModel fix(Dropdown,Combobox): fixed selection lost updating ListItems when using reactive forms or ngModel May 22, 2026
Comment thread src/combobox/stories/app-dynamic-list-combobox.component.ts Outdated
Comment thread src/combobox/stories/app-mock-query-search.component.ts Outdated
Comment thread src/combobox/combobox.component.ts Outdated
protected _isFocused = false;

private _writtenValue: any;
private _isUsingReactiveForms = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the changes in this file, I'm confused why this variable is called _isUsingReactiveForms. The changes made also impact Template driven forms.

So the question is, do we even need this check/variable? Shouldn't it be fixed for when we have one-way binding as well (non-reactive/non-template-driven -- passing in value and listening for change, updating value)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well...considering there is no input that can be used to pass the selection, yes we do need it. My suggestion for the next major is to remove the selected property from the listItem and have it handled as a separate input that would work in tandem with the writeValue flow bringing back the component to only have one source of truth for the selected values

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of _isUsingReactiveForms, should name it as _isUsingNgControl since it's being applied to both template-driven & reactive forms.

Comment thread src/dropdown/dropdown.component.ts Outdated
// primarily used to capture and propagate input to `writeValue` before the content is available
private _writtenValue: any = [];

private _isUsingReactiveForms = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above _isUsingReactiveForms.

Comment thread src/dropdown/dropdown.component.ts
@Licen-it Licen-it requested a review from Akshat55 June 22, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RadioGroup not updating selected value if options change Dropdown component racing condition issue with reactive forms

2 participants