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

[FEAT]: Have ability to sort selectedOptions first in useSelect #6061

Closed
Dominic-Preap opened this issue Jun 20, 2024 · 2 comments · Fixed by #6071, #6058 or #6105
Closed

[FEAT]: Have ability to sort selectedOptions first in useSelect #6061

Dominic-Preap opened this issue Jun 20, 2024 · 2 comments · Fixed by #6071, #6058 or #6105
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@Dominic-Preap
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Currently we use useSelect with defaultValue to add extra options in our select list. But when options have more records like 30-50 records so the selectedOptions is at the bottom.

We want selectedOptions at first position of the list.

useSelect({
  defaultValue: 1, // or [1, 2]
});

Describe alternatives you've considered

First option, we can switch the order of selectedOptions first then options.
image

Second option, have a property to sort by selectedOptions or options first.

useSelect({
  defaultValue: 1, 
 selectedOptionsSort: 'asc' | 'desc'  // <--- something like that, we can have better name than this.
});

Additional context

At the bove.

Describe the thing to improve

N/A

@Dominic-Preap Dominic-Preap added the enhancement New feature or request label Jun 20, 2024
@aliemir
Copy link
Member

aliemir commented Jun 21, 2024

Hey @Dominic-Preap thank you for the issue! I think this makes sense and can benefit many use-cases. 🚀 We've discussed on how we can implement those changes and decided like below:

type SelectedOptionsOrder = "in-place" | "selected-first";

type UseSelectProps<...> = {
  /* ... */
  selectedOptionsOrder?: SelectedOptionsOrder; // This will be default to "in-place" which is. the current behavior.
}

Then use the selectedOptionsOrder to determine the order in the line 365:

() => uniqBy([...options, ...selectedOptions], "value"),

Default value should be "in-place" in order to keep the current behavior as default.

There are also extensions of the useSelect hook such as useSelect from @refinedev/antd which may require small changes but I guess those won't take much time or might not require any change at all.

Do you want to work on this issue? We'd love to see your contribution 🙏 Check out our Contributing Guide to learn how to get started 🚀 🚀

Let us know if you can work on this and please let us know if you have any issues while working on it 💯

@aliemir aliemir added the good first issue Good for newcomers label Jun 21, 2024
@Dominic-Preap
Copy link
Contributor Author

Okay sure, you can assign to me. I'll work on it this weekend.

@aliemir aliemir added this to the July Release milestone Jun 21, 2024
@BatuhanW BatuhanW linked a pull request Jun 25, 2024 that will close this issue
5 tasks
@BatuhanW BatuhanW linked a pull request Jul 5, 2024 that will close this issue
@BatuhanW BatuhanW closed this as completed Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
3 participants