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

New setting 'blankSortBy' + minor bug fixes #36

Merged
merged 4 commits into from
Sep 16, 2016
Merged

New setting 'blankSortBy' + minor bug fixes #36

merged 4 commits into from
Sep 16, 2016

Conversation

colbysargentcodes
Copy link
Contributor

This new setting allows a different sort to be used when the input is
blank. 'initial' sort type does not apply any sorting, so will appear in
the same order as the original select options.

Minor bug fixes as detailed in 'Bug Fixes' commit

Colby Sargent and others added 4 commits September 16, 2016 16:43
This new setting allows a different sort to be used when the input is
blank. 'initial' sort type does not apply any sorting, so will appear in
the same order as the original select options.
Line 116:
allowMismatchBlank would set the value to blank, but the flexselect
would still reset the displayed selection if allowMismatch was false.
Add else to second if statement so both do not occur

Lines 119-120:
Remove dropdownList.show() on blur of flexselect when
hideDropdownOnEmptyInput=true, seems to serve no purpose.

Lines 239-245:
Move hide/show logic of hideDropdownOnEmptyInput to the end of
filterResults() instead of keyUp(). This will now apply when a
flexselect is clicked active.
Change dropdownList to dropdown, so an empty box with the border still
visible does not show
@rmm5t
Copy link
Owner

rmm5t commented Sep 16, 2016

'initial' sort type does not apply any sorting, so will appear in the same order as the original select options.

Could you help me here and give me some concrete use-cases as to why you'd want to change this default (blank input) sort behavior? Especially, why should score be an option here? Also, if you wanted to sort alphabetically, why not just ensure that your <option> elements are already sorted?

@colbysargentcodes
Copy link
Contributor Author

colbysargentcodes commented Sep 16, 2016

Hi,

I used this plug-in (great by the way! thanks!) in a project of mine where the users needed to filter a large list of clients, scoring was the best way to sort these with an appropriate search. When the input was blank, it would still use score (hence ensuring the <option> elements are already sorted doesn't help), and so the returned order seemed very messy and random to them. I think having the results in alphabetical order when no search is provided makes it look a lot neater and friendlier for the user.

Sorting by name/alphabetically was the main purpose when I built this, I only implemented score as the function was already there anyway and to keep options consistent (was also considering suggesting initial as a sortBy option in the in-line comment).

While the vast majority of cases would be better with name or score sorting, I do believe there's the odd case which could make use of it, and since it doesn't even need extra coding, it doesn't exactly hurt. It may help on any select where elements have previously been sorted with its own criteria prior to creating the flexselect. An example that comes to mind could be a list of music albums, previously sorted by date, which may want to keep its order without the need of prepending that information to the option name.

@rmm5t
Copy link
Owner

rmm5t commented Sep 16, 2016

Ah! Thanks for the detailed follow-up. This helps a ton, and I'm much more willing to pull this in now.

@rmm5t rmm5t merged commit 1c44bdd into rmm5t:master Sep 16, 2016
@rmm5t
Copy link
Owner

rmm5t commented Sep 16, 2016

Thanks for this. I just merged it in, but I also added a bit of a refactoring of it. Note the changes here: f00524c

  1. Made initial the default blankSortBy setting.
  2. Simplified the logic for determining the sortBy behavior at runtime.

@rmm5t
Copy link
Owner

rmm5t commented Sep 16, 2016

v0.9.0 released!

@colbysargentcodes
Copy link
Contributor Author

Looks great! Glad I could contribute.

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

Successfully merging this pull request may close these issues.

2 participants