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: Infinite loop dynamic options array #14319

Closed
kmarzinadv opened this issue Dec 11, 2023 · 4 comments
Closed

Dropdown: Infinite loop dynamic options array #14319

kmarzinadv opened this issue Dec 11, 2023 · 4 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@kmarzinadv
Copy link

Describe the bug

Since primeng 17 we can not pass a function or a getter wich build or filter an array to the OPTIONS parameter of a primeng dropdown. In this case, an infinite loop ocure in the browser. This behavior work well with angular 16.2.12 and primeng 16.6.0 (see stackblitz example). I didn't find a workaround yet.

Environment

Reproductible with last angular 17 version and last primeng 17 version only.

Reproducer

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

Angular version

17.0.0

PrimeNG version

17.0.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.10.0

Browser(s)

Chrome 119.0.6045.160

Steps to reproduce the behavior

Run the stackblitz example with angular 17.0.0 and primeng 17.0.0. The browser will loop.
Comment the two last dropdown of app.component.html and then it work.

Expected behavior

Same behavior of primeng 16 is expected. No infinite loop with two last dropdown uncommented. The last dropdown must display everything except ROME.

@kmarzinadv kmarzinadv added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 11, 2023
@horizoncarlo
Copy link

Ran into this as well, took a while track down what was pegging the browser

@pablo191f
Copy link

I have the same problem. I hope for a quick fix.

@cetincakiroglu cetincakiroglu added this to the 17.3.2 milestone Jan 8, 2024
@cetincakiroglu cetincakiroglu self-assigned this Jan 8, 2024
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jan 10, 2024
cetincakiroglu added a commit that referenced this issue Jan 10, 2024
@pratyush22
Copy link

It's good that this bug is fixed. It maintains backward compatibility.

But think about the solution which is implemented. The infinite loop was occurring because, as per my best guess, the dynamic arrays which were getting created and assigned to some property, angular change detection was triggered and with every change detection cycle, the dynamic array is again created and the cycle continues.

Now, to solve this, we are checking deep equality. So, consider a situation where we have multiple dropdowns on each page and have a good amount of options for each one of them. Will it not impact performance when deep equality is checked on long lists on each detection cycle?

Right way to fix it will be to gradually remove dynamic arrays from the code and create the lists on specific events. Thoughts?

@cetincakiroglu
Copy link
Contributor

cetincakiroglu commented Jan 18, 2024

To improve further, we'll replace the getter & setters in list inputs (dropdown, multiselect, listbox etc.) with signal inputs once Angular team releases the feature. Tested in the virtualScroll to see the behavior with large lists, there wasn't a significant difference. But deep equality check will be replaced in the future.

@cetincakiroglu cetincakiroglu added LTS-PORTABLE Issue's fix will be ported to supported LTS versions LTS-16-PORTABLE and removed LTS-PORTABLE Issue's fix will be ported to supported LTS versions labels Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

6 participants