-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
maxOptions display bug #2593
Comments
I found the same bug, max-options wasn't work, please help and fix it in 1.14.0-beta2 |
Found the same one Plnkr link: https://plnkr.co/edit/c204mzsHoyfQ4vNB to reproduce |
Hi, I'm new to use bootstrap-select, and see the same displaying icon error |
Possible workaround: // "dropdown" is the boostrap-select element, that contains the <ul>
// "element" is the associated <select> element
// Workaround for https://github.com/snapappointments/bootstrap-select/issues/2593
// must be called after bootstrap-select initialization (ie. after calling $('select').selectpicker())
dropdown.querySelector('.inner').addEventListener("click", e => {
// ignore workaround if already selected. allows deselecting items
if (e.target instanceof HTMLElement && e.target.closest('li').classList.contains('selected')) return;
const maxOptions = Number.parseInt(element.dataset.maxOptions);
// maximum number of items reached?
if (!Number.isNaN(maxOptions) && element.selectedOptions.length >= maxOptions) {
// "cancel" click event, which prevents bootstrap-select's setSelected() from being called.
e.stopPropagation();
}
}, true /* in capture phase */); I guess this also prevents the maxOptionsText notice to appear. |
HI, I found the simplest solution: In bootstrap-select.js in event:
Can anybody commit this change? |
@margiel The line: bootstrap-select/js/bootstrap-select.js Line 2623 in 225ca0a
setTimeout(function () {
that.setSelected(clickedIndex, false);
}, 10);
|
My solution is for code from: |
jQuery version: 3.5.1
Bootstrap version: 5.0.0-beta3
bootstrap-select version: 1.14.0-beta2
Browser: Firefox
If I create a select with BS5 which is limited by the "max-options" parameter and click on options after the max limit is reached, the options will be still marked with an icon. But these options aren't really selected, so it seems it is an display bug.
Here is a codepen example: https://codepen.io/dernst/pen/abpperx
The text was updated successfully, but these errors were encountered: