Skip to content
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

[DropDownTree] Value cannot be updated in Reactive Forms #4389

Open
mbechev opened this issue Aug 27, 2024 · 0 comments
Open

[DropDownTree] Value cannot be updated in Reactive Forms #4389

mbechev opened this issue Aug 27, 2024 · 0 comments

Comments

@mbechev
Copy link
Contributor

mbechev commented Aug 27, 2024

The value of the DropDownTree cannot be programmatically changed in Reactive form when the user already selects an option from the list.

To Reproduce

  1. Select any option from the DropDownTree.
  2. Click update value button.

https://stackblitz.com/edit/angular-nefwjc-fkckmc?file=src%2Fapp%2Fapp.component.ts

Expected behavior
The value needs to be updated programmatically regardless of the selection. Like the DropDownList:

https://stackblitz.com/edit/angular-nefwjc-v4vrfy

Workaround

Reset the form or just the form control that corresponds to the DropDownTree before reassigning the component value:

  public selectValue() {
    this.form.controls['item'].reset();
    this.form.controls.item.setValue({ text: 'Tables & Chairs', id: 2 });
  }
  public selectValue() {
    this.form.reset();
    this.form.controls.item.setValue({ text: 'Tables & Chairs', id: 2 });
  }

https://stackblitz.com/edit/angular-nefwjc-xkc7gg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant