-
Notifications
You must be signed in to change notification settings - Fork 36
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
Option grouping #135
Comments
Why do they need to be in 1 multi-select? And what would the UI for that look like? How would you have 3 dropdowns in one component? Maybe you can elaborate on your use case. |
Hey thanks for the quick reply - I'm referring to a binding to the HTML https://developer.mozilla.org/en-US/docs/Web/HTML/Element/optgroup |
Ah, you're talking about grouping of options. Yes, I'd be happy to take a PR for that. I should say upfront though, this sounds like a fair amount of work if you want to do it right. Your example suggests that you don't just want option grouping in the UI but for the groups to have separate
|
Yes, exactly - not quite just the grouping of options, since the intention is to group other attributes from
<script>
import MultiSelect from 'svelte-multiselect'
const genreTags = {label: "Genre", options: [`Rock`, `Electronic`, `Opera`]}
const keyTags = {label: "Key", options: [`C`, `D`, `E`, `F`, `G`, `A`, `B`]}
const scaleTags = {label: "Scale", options: [`Major`, `Minor`]}
let selectedTags = []
</script>
<MultiSelect
bind:selected
options={[genreTags, keyTags, scaleTags]}
maxSelect={[null, 1, 1]}
required={[true, true, false] }
allowUserOptions={ [true, false, true] }
placeholder="Select Tags"
/>
|
As I said, happy to take a PR for this. Though the default way to group options should be an object of arrays imo: <script>
import MultiSelect from 'svelte-multiselect'
const options: Record<string, Option[]> = {
Genre: [`Rock`, `Electronic`, `Opera`],
Key: [`C`, `D`, `E`, `F`, `G`, `A`, `B`],
Scale: [`Major`, `Minor`],
}
let selected = []
</script>
<MultiSelect
bind:selected
{options}
maxSelect={[null, 1, 1]}
required={[true, true, false]}
allowUserOptions={[true, false, true]}
placeholder="Select Tags"
/> We can expand to options: Record<string, { label: string, options: Option[], required: boolean, maxSelect: number | null }> later. |
Sorry @janosh bit too pressured at work to get onto doing this properly - working around it for now. Anyone else wants to jump in please do |
Hi, just wondered if there was any update on this, or if there is a branch I could take a look at to help towards implementing this? |
@MaxJW No progress here yet but PRs still welcome! |
This is a perfect little component. In some cases where there are many fields it would be nice if a single Multiselect could contain several options, perhaps like this:
I need this in my app - are you open to an PR (if this isn't already supported)?
The text was updated successfully, but these errors were encountered: