Rmwc: feat: support list groups in enhanced `Select`

Created on 19 Apr 2020  路  4Comments  路  Source: jamesmfriedman/rmwc

Right now, there's no way to add ListDividers to an enhanced Select component (without building the component yourself using a composition of a readOnly controlled TextField and Menu).

It'd be nice to be able to do something like this:

<Select enhanced options=[
  { label: 'Option #1', value: 1 }, 
  { type: 'divider' }, 
  { label: 'Option #2', value: 2, type: 'option' },
] />

Where the type property would be optional (and would default to option).

See this issue for my current application (i.e. how this feature would be used).

feature request

Most helpful comment

Threw this in as well, will be live shortly with 6.1.0

All 4 comments

They're already supported actually. Straight from the docs

<Select
  label="Formatted"
  enhanced
  options={[
    {
      label: 'Dinner',
      options: [
        {
          label: 'Pizza',
          value: '2'
        }
      ]
    },
    {
      label: 'Dessert',
      options: [
        {
          label: 'Cookies',
          value: '1'
        },

        {
          label: 'Icecream',
          value: '3'
        }
      ]
    }
  ]}
/>

If you don't want the section labels, just pass empty strings.

Yeah @jamesmfriedman, but it looks like it still inserts a <div class="mdc-list-group__subheader" /> which I don't want:

Screenshot 2020-04-21 at 1 52 01 PM

Those subheaders make the divisions between the lists uneven (i.e. it looks like there's a lot more padding before the list than after it to the end user).

Could you make it omit those subheaders when we pass a null or empty string label?

Threw this in as well, will be live shortly with 6.1.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

UFOMelkor picture UFOMelkor  路  6Comments

darrencruse picture darrencruse  路  6Comments

victorandree picture victorandree  路  5Comments

alecchisi picture alecchisi  路  5Comments

peterkle picture peterkle  路  6Comments