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

Disabling exact match and automatic sorting #16881

Open
gtaasaan opened this issue Mar 30, 2016 · 6 comments
Open

Disabling exact match and automatic sorting #16881

gtaasaan opened this issue Mar 30, 2016 · 6 comments

Comments

@gtaasaan
Copy link

There might be a common case to disable displaying only exact matches and removing auto-sorting (sorting before I'm passing the list to awesomplete).

I think the library should have a feature to disable both of these functionalities.

@fractaledmind
Copy link

Can't you simply override the filter and sort methods to be essentially non-functional?

@i-like-robots
Copy link

i-like-robots commented Jun 16, 2016

Unfortunately making sort non-functional for an array of objects is not quite possible:

If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.

So sort = () => 0 will still sort, E.G. http://jsbin.com/pegojeguve/1/edit?js,console

@vlazar
Copy link
Collaborator

vlazar commented Jun 17, 2016

Related #16771 and Lea's comment #16771 (comment)

@Chris7
Copy link

Chris7 commented Jul 26, 2016

There is a way around this bug -- add a key to your object that indicates sorting order and sort on it.

@Greggsterr
Copy link

For what it's worth, if you comment out .sort(this.sort) (which should be around line 239) then sorting is disabled.

@leondevries
Copy link

For people that can't wait till 1.1.2 is released:

aMyArray = ['a', 'aa', 'abc'];
this.Awesomplete = new Awesomplete(input, {
list: aMyArray,
autoFirst: true,
minChars: 0,
maxItems: 999,
sort: (a, b) => {
return aMyArray.indexOf(a.label) < aMyArray.indexOf(b.label) ? -1 : 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

7 participants