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

Feature Request - Sorting Options Based on Search Query #839

Open
fakkio opened this issue Jan 23, 2024 · 0 comments
Open

Feature Request - Sorting Options Based on Search Query #839

fakkio opened this issue Jan 23, 2024 · 0 comments

Comments

@fakkio
Copy link

fakkio commented Jan 23, 2024

Is your feature request related to a problem? Please describe.
I often find myself in a situation where I need to sort the options based on the user's search query. Currently, I resort to implementing a fake-asynchronous search to achieve the desired sorting of results, but it would be more efficient and cleaner to have a native feature for sorting based on the search query.

Describe the solution you'd like
I would like to propose the addition of a new property, sortBy, that can be utilized alongside filterBy. This property should allow users to specify a custom sorting function that will be applied to the filtered options based on the user's search query. For example:

<Typeahead
  // existing props...
  filterBy={(option, props) => {/* existing filter logic */}}
  sortBy={(options, props) => {
    // Custom sorting logic based on the search query
    // ...
    return sortedOptions;
  }}
/>

How is this solution useful to others?
This feature would be beneficial for scenarios where users expect a customized sorting order based on their search input. It provides a more flexible and generalized way to handle result sorting, addressing a common use case across various applications.

Describe alternatives you've considered
As mentioned earlier, the current workaround involves implementing a simulated asynchronous search to manually sort the results in the onSearch handler. However, having a built-in option for dynamic sorting based on the search query would streamline the process and make the code more maintainable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant