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

"Deselect All" doesn't consistently work with virtual scroll #2352

Closed
chadrjohnson opened this issue Nov 6, 2019 · 3 comments
Closed

"Deselect All" doesn't consistently work with virtual scroll #2352

chadrjohnson opened this issue Nov 6, 2019 · 3 comments

Comments

@chadrjohnson
Copy link

Environment
Chrome (mac), 78.0.3904.87
jQuery 3.3.1
bootstrap 3.4.1
bootstrap-select 1.13.12
angularjs 1.7.8

First of all, thanks for providing and maintaining a great plugin. It provides a lot of nice functionality for us.

Here's an edge case I encountered.

I have a selectpicker with a lot of options (~2000) and virtual scroll enabled. And the options are dynamically updated based on the value of a second selectpicker.

I can reproduce the issue with the following:

  1. Search for and select options that are outside the current view.
  2. Update the options via the second selectpicker, but where the current selections are still valid.
  3. Clicking on the "Deselect All" button does not deselect the options.

If there are any selected options within the current updated view, "Deselect All" works as expected. If a new option is selected, "Deselect All" works as expected. If I search for the selected options and bring them into the view, "Deselect All" works as expected. It's only when the options are outside the current view, the options are updated and the selectpicker refreshed, that the "Deselect All" step fails.

I can fix the issue with a small change to the "changeAll" method. In the case above, the "previousSelected" count is unexpectantly zero. However, the "prevValue" array is correct and represents the correct selections from step #1 above.

If I change line 2715 from:

if (previousSelected === currentSelected) return;

to

if (prevValue.length === currentSelected) return;

"Deselect All" works as expected.

Looking more closely at the "previousSelected" count, it seems that it's not correct when some of the previously selected options are in the current view and some are not.

@caseyjhol
Copy link
Member

Bug reports must include a live demo of the problem. Per our contributing guidelines, please create a reduced test case (you can use our preconfigured Plunker), and report back with your link.

@chadrjohnson
Copy link
Author

@caseyjhol
Copy link
Member

This appears to have been fixed in v1.13.13.

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

No branches or pull requests

2 participants