-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
p-dropdown: Not initializing the options if options set inside observable inside ngOnInit #14841
Comments
@mojo2405 Have you resolved this issue? |
Thank you! I just burned an entire day attempting to track this down, I can't believe it was something this simple. Every drop down in my application is broken after this upgrade, and I only upgraded because multiselect filter is broken in 16! |
Can someone look into this? We would really appreciate it! |
I managed to reproduce this even without a subscription block. In this case it is after the view is initialized. |
@mojo2405 and @SMayer135 I found a workaround: https://stackblitz.com/edit/scbcb5-kwhdeq?file=src%2Fapp%2Fdemo%2Fdropdown-virtualscroll-demo.ts Basically instead of:
Do instead:
You cannot use the push function specifically on the array used in options. If you do it seems to cause this bug. Even if you reassign the array after push (with the spread operator) the bug still persists. I am not sure of the real fix but this workaround works for now. |
Hi, So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you open a new issue so we can include it in our roadmap? Thanks a lot for your understanding! |
Describe the bug
When setting the options attribute inside a p-dropdown inside the ngOnInit function, it will not work if the options parameter is not initialized inside the subscription block.
Environment
https://stackblitz.com/edit/scbcb5-ywrxtb?file=src%2Fapp%2Fdemo%2Fdropdown-virtualscroll-demo.ts
Reproducer
stackblitz
Angular version
17.8.5
PrimeNG version
17.7.0
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18.8.0
Browser(s)
Chrome
Steps to reproduce the behavior
Create an observable and subscribe to it inside the ngOnInit function, and set the options parameters of the p-dropdown component inside the subscription block. If the options parameter is not initialized inside the subscription block - the options will not be selectable inside the component(it will be shown but not selected).
in the example - uncommenting line 25 will solve the issue.
Expected behavior
you don't need to initialize the options parameters inside the subscription block; it should work if you initiated it before.
The text was updated successfully, but these errors were encountered: