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

[New Menus] Nested Support #1517

Closed
chrismcv opened this issue Aug 26, 2015 · 12 comments
Closed

[New Menus] Nested Support #1517

chrismcv opened this issue Aug 26, 2015 · 12 comments
Labels
component: menu This is the name of the generic UI component, not the React module!

Comments

@chrismcv
Copy link
Contributor

Hi,
Just wondering what the status of nested support is with new menus - the ListItem being used seems to support some variation of this, but it doesn't look menu friendly - it just indents.

What is needs done to support this? Happy to help.

Chris

@jbbae
Copy link

jbbae commented Aug 30, 2015

+1

2 similar comments
@cristiano-belloni
Copy link

+1

@afhammad
Copy link

+1

@alitaheri alitaheri reopened this Dec 8, 2015
@chrismcv
Copy link
Contributor Author

chrismcv commented Dec 8, 2015

@subjectix happy to close this

@alitaheri
Copy link
Member

@chrismcv can menus be nested now? I haven't had the time to tackle them.

@chrismcv
Copy link
Contributor Author

chrismcv commented Dec 8, 2015

@chrismcv chrismcv closed this as completed Dec 8, 2015
@alitaheri
Copy link
Member

Oh, right. Nice work 👍 👍

@STRML
Copy link
Contributor

STRML commented Jan 4, 2016

@chrismcv What's a good way to mark a nested menu item as selected? Going for a LeftNav similar to the one on https://www.google.com/design/spec/components/subheaders.html#subheaders-menu-subheaders

Happy to make a new issue if you think it's necessary.

@oliviertassinari
Copy link
Member

@STRML Having a look at your example, I think that a <List /> would be more appropriate that a <Menu />.
capture d ecran 2016-01-04 a 21 52 22

@STRML
Copy link
Contributor

STRML commented Jan 4, 2016

Thanks. It's a bit tricky to get working with nested <SelectableList>s. For posterity, here's what worked for me (based on PageWithNav from the docs):

menu(items, styles, nestedLevel=0) {
  return (
    <SelectableList
      autoWidth={false}
      desktop={true}
      valueLink={{value: this.state.activeRoute, requestChange: this.handleUpdateRoute}}
      openDirection="bottom-right"
      style={nestedLevel === 0 ? styles.secondaryNav : {}}
      value={this.state.activeRoute}
      width={styles.secondaryNav.width}
      selectedItemStyle={{
        color: this.context.muiTheme.rawTheme.palette.accent1Color,
      }}
      zDepth={0}>
      {_.flatten(items.map((item, index) => 
        this.menuItem(item, index, styles, nestedLevel)))}
    </SelectableList>
  );
},

menuItem(item, index, styles, nestedLevel) {
  if (item.divider) return <Divider key={index} />;
  let out = [
    <ListItem
      key={index}
      primaryText={item.text}
      data-route={item.route}
      value={item.route}
      onTouchTap={this.onItemTouchTap}
      initiallyOpen={true}
      desktop={true}
      autoGenerateNestedIndicator={false}
      nestedLevel={nestedLevel}
    />
  ];
  if (item.nested) {
    out.push(this.menu(item.nested, styles, nestedLevel + 1));
  }
  return out;
},

render() {
  let styles = this.getStyles();
  const menuItems = [
    {route: '/a', text: 'Item A', nested: [
      {route: '/a_a', text: 'Nested Item A'}
      {route: '/a_b', text: 'Nested Item B'}
    ]},
    {route: '/B', text: 'Item B'},
    {divider: true},
    {route: '/C', text: 'Item C'},
  ];
  return this.menu(menuItems, styles);
}

@oliviertassinari
Copy link
Member

I'm happy you found a solution, and thanks for sharing that may help other 👍.

Is the flatten really needed? I though react was doing it for us.

@STRML
Copy link
Contributor

STRML commented Jan 4, 2016

Thanks - you're correct, the _.flatten() isn't necessary.

mnajdova pushed a commit to mnajdova/material-ui that referenced this issue Nov 10, 2020
* Remvoe focusRipple and better selected + focus state managment

* Do not show outline on touch devices

* Do not focus current day and year by default in static mode

* Render better date for placeholder by default
@zannager zannager added the component: menu This is the name of the generic UI component, not the React module! label Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

8 participants