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

Dropdown: Issue with selecting value when using reactive form #14844

Closed
tommskar opened this issue Feb 20, 2024 · 1 comment
Closed

Dropdown: Issue with selecting value when using reactive form #14844

tommskar opened this issue Feb 20, 2024 · 1 comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@tommskar
Copy link

tommskar commented Feb 20, 2024

Describe the bug

I have a reactive form setup and I'm trying to select a value in the dropdown using FormGroup.patchValue(...) with the object that was selected.

This works as expected for a native select setup but when using the same approach for a PrimeNG dropdown setup it fails to render the text (meaning the placeholder is still visible) and it doesn't mark the expected option as selected when clicking the dropdown afterwards. However, the reset button does get triggered.

Environment

Chrome 121.0.6167.184 on Windows 11

Reproducer

https://stackblitz.com/edit/github-sbij3t?file=src%2Fapp%2Fapp.component.ts

Angular version

17.1.3

PrimeNG version

17.7.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.10.0

Browser(s)

No response

Steps to reproduce the behavior

See reproducer for a concise example.

Expected behavior

The dropdown should reflect the changes made to the form group.

@tommskar tommskar added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 20, 2024
@tommskar
Copy link
Author

It seems you cannot pass the selected object to FormGroup.patchValue(...) but instead you have to pass the property defined by optionValue on the Dropdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant