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

csvDispCount off by 1 #267

Closed
ameyajoshi88 opened this issue Jan 10, 2019 · 1 comment
Closed

csvDispCount off by 1 #267

ameyajoshi88 opened this issue Jan 10, 2019 · 1 comment

Comments

@ameyajoshi88
Copy link

According to the documentation:

csvDispCount (int) The number of items to be displayed in the widget seperated by a , after that the text will be warped as 3+ Selected. Set 0 for all the options.

So, when I specify csvDispCount: 4, I expect the following:

<=4 selected - The select box should display the labels in comma separated format
>4 selected - The select box should display 'n Selected'

However, right now it will behave as follows:

<=3 selected - The select box will display the labels in comma separated format
>3 selected - The select box will display 'n Selected'

I would recommend changing

for (var i = 0; i < sels.length; i++) {
    if (i + 1 >= settings.csvDispCount && settings.csvDispCount) {
        if (sels.length === O.E.find('option').length && settings.captionFormatAllSelected) {
            O.placeholder = settings.captionFormatAllSelected.replace(/\{0\}/g, sels.length) + ',';
        } else {
            O.placeholder = settings.captionFormat.replace(/\{0\}/g, sels.length) + ',';
        }

        break;
    }
    else O.placeholder += $(sels[i]).text() + ", ";
}

to

if (settings.csvDispCount && sels.length > settings.csvDispCount) {
    if (sels.length === O.E.find('option').length && settings.captionFormatAllSelected) {
        O.placeholder = settings.captionFormatAllSelected.replace(/\{0\}/g, sels.length) + ',';
    }
    else {
        O.placeholder = settings.captionFormat.replace(/\{0\}/g, sels.length) + ',';
    }
}
else {
    for (var i = 0; i < sels.length; i++) {
        O.placeholder += $(sels[i]).text() + ", ";
    }
}

in the setText function to fix the issue as well as make the code cleaner.

@Zenoo Zenoo closed this as completed in dd00654 Jun 20, 2021
@Zenoo
Copy link
Collaborator

Zenoo commented Jun 20, 2021

Thanks ! This should be fixed in v3.3.1

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