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

Rationale behind sorting filtered options #1763

Open
thomaspaillot opened this issue Apr 10, 2024 · 0 comments
Open

Rationale behind sorting filtered options #1763

thomaspaillot opened this issue Apr 10, 2024 · 0 comments

Comments

@thomaspaillot
Copy link

function filterOptions (options, search, label, customLabel) {
return search ? options
.filter((option) => includes(customLabel(option, label), search))
.sort((a, b) => customLabel(a, label).length - customLabel(b, label).length) : options
}

I would like to understand the rationale behind the sort mechanism of the filtered options. As I understand it, it is sorted by the option label length, it seems to me that this is quite an opiniated choice that will not produce good result in every cases. Would you be willing to introduce a new prop to provide a custom sort function or to remove the sort?

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

1 participant