Skip to content

Conversation

ChildishGiant
Copy link
Member

Remake of #116. Also renamed sortFunction to compareFunction (Closes #115)

Proposed changes

Currently you can specify a custom "sortFunction" but this only controls which element wins in a 1v1 matchup, not how the matchups are made (Currently just uses array.sort). Adding this would allow end users to use libraries such as fuse.js to do more complex sorting and make results more accurate.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to change).

Checklist:

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

BREAKING CHANGE: renamed sortFunction to compareFunction
@ChildishGiant ChildishGiant linked an issue Sep 22, 2021 that may be closed by this pull request
@ChildishGiant ChildishGiant added this to the 2.0.0 milestone Sep 22, 2021
@ChildishGiant ChildishGiant requested a review from a team September 22, 2021 03:15
Copy link
Member

@Smankusors Smankusors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ehm wait, currently the docs now moved into the pug folder, while your PR still on the jade folder...

hmm, I don't know what will happen really if we merge this 😅


Oh wait, this PR will be merged to v2-dev branch?

@ChildishGiant
Copy link
Member Author

Currently The v2-dev branch is a bit behind on some critical things (mainly jade-> pug and the GitHub actions fix). It'll be rebased onto main and then this pr will need updating I suppose. Good spot 😊

data: defaultData,
filterFunction: function (key_string, filter_string) {
compareFunction: function (key_string, filter_string) {
return true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think returning true for a compareFunction is a bit weird. But it made sense for a thing called filterFunction. Don't you think?
Why did this line change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my knowledge, filterFunction never existed, this is the only reference to it I can find. I'd consider using the name over compareFunction as I agree that it makes a bit more sense. Filter function to me, however does imply that things would be removed from the results but that's not the case. Maybe @samschurter could give some insight as they introduced this line (infact the whole file).

@LoganTann
Copy link

Any updates about this PR ?

@wuda-io
Copy link
Member

wuda-io commented Jan 11, 2022

Can this PR be closed?
I will start a PR for Autocomplete soon with the Data as Array.
This has to be done...

@wuda-io
Copy link
Member

wuda-io commented May 12, 2022

This will be obsolete with #261
So i will close for now... Feel free to re-open

@wuda-io wuda-io closed this May 12, 2022
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.

Option for custom sort in autocomplete
5 participants