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

Groups? #103

Closed
gr8bit opened this issue Mar 2, 2021 · 8 comments
Closed

Groups? #103

gr8bit opened this issue Mar 2, 2021 · 8 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@gr8bit
Copy link

gr8bit commented Mar 2, 2021

Hi all,

one feature the vue-select-package was (and is!) missing is the possibility to have option groups (similar to the html select). Anyone thought about this yet?

Feature wishlist:

  • "Group options" (=the option that is a group "headline") selectable or not selectable and with own option value
  • Nested groups on 1+ levels
  • Individual "group option" and options in group rendering (slots?) per level

Cheers! :)

@soc221b soc221b added the enhancement New feature or request label Mar 2, 2021
@valh1996
Copy link

+1 I am really looking for that! I can't find any alternative components on Vue3...

@soc221b soc221b added the help wanted Extra attention is needed label Mar 21, 2021
@soc221b
Copy link
Owner

soc221b commented Mar 24, 2021

@gr8bit @valh1996 Sorry for not getting back to you sooner.

In order to support as many as possible use cases (e.g, nested groups) and keep it flexible as well, it would be great if there have a prop group-by which is used to determine whether an option is group.

When click on a group option, all of its values (the value must be an Array) will be selected.

  1. Group options, use disabled (for now) to prevent select on group.
const options = ref([
  { value: ['i', 'love', 'vue'], group: true }, // click on this group option will select all options, and deselect all options if those options are already selected.
  { value: 'i' },
  { value: 'love' },
  { value: 'vue' },
])
  1. Nested group options can be:
const options = ref([
  { value: ['1-1-1', '1-1-2', '1-2-1', '1-2-2'], group: true },
  { value: ['1-1-1', '1-1-2'], group: true },
  { value: '1-1-1' },
  { value: '1-1-2' },
  { value: ['1-2-1', '1-2-2'], group: true },
  { value: '1-2-1' },
  { value: '1-2-2' },
])
  1. There is no needed to add another slot, just use the dropdown-item slot to achieve this:
const options = ref([
  { value: ['i', 'love', 'vue'], group: true, level: 1 }, // you can add any info to option, it could help you to determine the level is or else.
  { value: 'i' },
  { value: 'love' },
  { value: 'vue' },
])

I have added some test cases for this blueprint too, please see this test file.

Thank you for your time.

@gr8bit
Copy link
Author

gr8bit commented Mar 24, 2021

@iendeavor very cool! One thought though: what about disabling a group of elements...?

Maybe disabled: true on the group could disable all of its values while disabled: ['i', 'love'] could be used as an alternative syntax to only disable certain elements of the group.
But how could we handle nested groups? We could simply disable groups if all of their elements were disabled. If there's a top level group which disables all the entries of two "inner" groups as in your example, these would then also be disabled, implicitly.

@soc221b
Copy link
Owner

soc221b commented Mar 24, 2021

Maybe there should add group-disabled-by prop?

@gr8bit
Copy link
Author

gr8bit commented Mar 24, 2021

I think the normal disabled-by/disabled mechanism should suffice for the groups as well.

@soc221b
Copy link
Owner

soc221b commented Mar 24, 2021

Yes, you are right 👍 , I will keep this in mind, but I have to go to sleep now 😄 .

@gr8bit
Copy link
Author

gr8bit commented Mar 24, 2021

Well deserved! 😄

@soc221b soc221b mentioned this issue Mar 28, 2021
3 tasks
soc221b pushed a commit that referenced this issue Mar 30, 2021
@soc221b
Copy link
Owner

soc221b commented Apr 3, 2021

It is released 😄 .

@soc221b soc221b closed this as completed Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants