Skip to content

[WIP] option groups #59#480

Closed
colbyr wants to merge 13 commits intoJedWatson:masterfrom
colbyr:opt-groups
Closed

[WIP] option groups #59#480
colbyr wants to merge 13 commits intoJedWatson:masterfrom
colbyr:opt-groups

Conversation

@colbyr
Copy link

@colbyr colbyr commented Sep 24, 2015

Spent some time working on grouped options for #59. Still rough around the edges but far enough along to share. I'd rather get some feedback before I spend too much time on it 😉

react-select-groups

I think I'd prefer a nested structure to a separate "groups" prop. It should work with any number of sub groups as well.

<Select
  options={[{
    label: 'Even',
    options: [
      { label: 'two', value: 2},
      { label: 'four', value: 4 },
    ]
  }, {
    label: 'Odd',
    options: [
      { label: 'One', value: 1 }
    ]
  }]}
/>

TODO

  • disabled groups
  • tests
  • better group styles?
  • for multi={true} allow group selection

cc @banderson

@jaimerson
Copy link

❤️ 💚 💙 💛 💜

@ESWAT
Copy link

ESWAT commented Nov 19, 2015

Awaiting this with bated breath. 👍

@nickblumenthal
Copy link

Same here!

@mping
Copy link

mping commented Dec 11, 2015

@colbyr need some help?

@mqklin
Copy link

mqklin commented Dec 26, 2015

Guys, i have a workaround:

//react-select-groups.scss
.Select-menu-outer {
  .Select-option {
    padding-left: 2em;
  }
  .Select-option.is-disabled {
    cursor: default;
    padding-left: 1em;
    font-weight: bold;
  }
}

Then you have to just push disabled values into options with labels that are group names:

//my-component.js
...
let options = [];
options.push({
  label: "Пользователи",
  value: "someUniqueValue",
  disabled: true
});
users.map((user) => {
  options.push({
    label: user.name,
    value: user.id,
  });
});
...

Result:
123

@oyeanuj
Copy link

oyeanuj commented Dec 31, 2015

@colbyr This looks great! Are you planning to have it ready for 1.0 final version? @JedWatson, thoughts?

@colbyr
Copy link
Author

colbyr commented Jan 2, 2016

I'll gladly polish this up if this is the direction @JedWatson wants to go!

@TrevorBurnham
Copy link

@JedWatson I believe this would be a strong addition to react-select.

@vgoklani
Copy link

vgoklani commented Feb 2, 2016

👍

2 similar comments
@gondalez
Copy link

+1

@jakedahm
Copy link

+1

@max-mykhailenko max-mykhailenko mentioned this pull request Feb 29, 2016
@max-mykhailenko
Copy link

When do you plan to merge this? How I can help?

@banderson
Copy link
Contributor

@max-mykhailenko I heard @TrevorBurnham (above) has been working on this functionality in a fork if you want to reach out!

TrevorBurnham pushed a commit to HubSpot/react-select-plus that referenced this pull request Mar 7, 2016
@TrevorBurnham
Copy link

The fork @banderson mentioned is now public. We're calling it React Select Plus. It adds option group support as well as some other small features. Please give it a try and let us know what you think!

All of us at HubSpot would still be very happy to see option group functionality added to JedWatson/react-select. /cc @JedWatson

@cedricmessiant
Copy link

@TrevorBurnham @banderson @JedWatson Should I use React Select Plus or is there a chance for this feature to be added in React Select ? Is there a pull request ?

@TrevorBurnham
Copy link

@cedricmessiant I'd be happy to create an up-to-date pull request if the React Select maintainers expressed interest.

@clbn
Copy link

clbn commented Mar 22, 2016

@TrevorBurnham JFYI, there's a bug with "multi + optgroups" in React Select Plus.

@TrevorBurnham
Copy link

@clbn Yes, I saw. I just haven't gotten to it yet.

@vgoklani
Copy link

@mqklin - your workaround works perfectly.

@kmudrick
Copy link

kmudrick commented May 6, 2016

@mqklin this workaround works (thanks!), but with 1.0.0-beta seems to automatically scroll to the first non disabled option (see #825)

@lalitkapoor
Copy link

+1

@M3lkior
Copy link

M3lkior commented Jun 30, 2016

I need this feature too !

@evgenTraytyak
Copy link

+1

@evgenTraytyak
Copy link

@colbyr how can I help you with this PR?

@colbyr
Copy link
Author

colbyr commented Jul 8, 2016

@evgenTraytyak this PR is pretty stale so I'm going to close it. Feel free repurpose it if you want.

I've been using the react-select-plus fork which supports option groups. The optgroups issue is still open if you want to weight in there #59.

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

Successfully merging this pull request may close these issues.