Skip to content

select: fix maximum call stack size error and improve performance in multiple mode #17062

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

Closed
wants to merge 4 commits into from

Conversation

ogix
Copy link
Contributor

@ogix ogix commented Sep 12, 2019

These changes fix "Maximum call stack size exceeded" error when selecting lots of options by value (e.g. clicking on a button).
Also improve performance by checking which options have to be selected/deselected when a new value comes in. Currently SelectionModel is cleared and options are selected by one every time select value changes. This leads to poor performance when there are many options.

Fixes #12504

Checks if option selection state in SelectionModel is different than the option selected value. Fixes "Maximum call stack size exceeded" error.
…iple mode

These changes check which options should be selected/deselected when a new value comes in instead of clearing SelectionModel and then selecting by one.
@ogix ogix requested a review from crisbeto as a code owner September 12, 2019 08:08
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 12, 2019
@crisbeto
Copy link
Member

This is being handled by #12517 already.

@ogix
Copy link
Contributor Author

ogix commented Sep 12, 2019

@crisbeto I've seen your PR but I guess it only covers a case when you initialize with preselected options. When I was debugging select component code I noticed that 950 line calls this._selectionModel.select(option) again after it was called by _setSelectionByValue which causes Maximum call stack size exceeded error so I've added a check that checks if option selected value is different than in SelectionModel

@ogix
Copy link
Contributor Author

ogix commented Sep 13, 2019

After some testing I noticed that performance changes only improve performance when clicking on the "select all" button subsequently. It takes a bit longer on the first click. So I will close this PR and open another one only with recursive call fix.

@ogix ogix closed this Sep 13, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mat-select] Maximum call stack size exceeded in select with 1000+ options
3 participants