material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

AppBar on front page http://www.material-ui.com/#/components/appbar not working

Open vmaudgalya opened this issue 10 years ago • 18 comments

When I copy and paste the code below as is, I receive an error

<AppBar
  title="Title"
  iconElementLeft={<IconButton><NavigationClose /></IconButton>}
  iconElementRight={
    <IconMenu iconButtonElement={
      <IconButton><MoreVertIcon /></IconButton>
    }>
      <MenuItem primaryText="Refresh" />
      <MenuItem primaryText="Help" />
      <MenuItem primaryText="Sign out" />
    </IconMenu>
} />

screen shot 2015-12-07 at 12 23 32 pm

Even after specifying an index for each MenuItem, I still receive the following error: screen shot 2015-12-07 at 12 25 58 pm

I suspect MoreVertIcon returning null to be the cause of this issue - could you please look into this?

vmaudgalya avatar Dec 07 '15 20:12 vmaudgalya

@vmaudgalya can you please show your includes...

frnk94 avatar Dec 07 '15 20:12 frnk94

I'm importing the elements like this:

import { AppBar, IconButton, NavigationClose, MenuItem, IconMenu, MoreVertIcon } from 'material-ui'

Upon looking into the source, it seems that MoreVertIcon is actually being exported as NavigationMoreVert https://github.com/callemall/material-ui/blob/master/src/svg-icons/navigation/more-vert.jsx

vmaudgalya avatar Dec 07 '15 20:12 vmaudgalya

NavigationClose is an icon not a material-ui component do

var NavigationClose = require('material-ui/lib/svg-icons/navigation/close.js');

frnk94 avatar Dec 07 '15 20:12 frnk94


import React from 'react';
import { AppBar, IconButton, MenuItem, IconMenu, MoreVertIcon } from 'material-ui'
var NavigationClose = require('material-ui/lib/svg-icons/navigation/close.js');


export default React.createClass({

  render() {
    return (
      <AppBar
        title="Title"
        iconElementLeft={<IconButton><NavigationClose /></IconButton>}
        iconElementRight={
          <IconMenu iconButtonElement={
            <IconButton><MoreVertIcon /></IconButton>
          }>
            <MenuItem primaryText="Refresh" index={0} />
            <MenuItem primaryText="Help" index={1} />
            <MenuItem primaryText="Sign out" index={2} />
          </IconMenu>
      } />
    );
  }

});

I'm still receiving this error: screen shot 2015-12-07 at 12 36 26 pm

vmaudgalya avatar Dec 07 '15 20:12 vmaudgalya

Same for MoreVertIcon var MoreVertIcon = require('material-ui/lib/svg-icons/navigation/more-vert');

frnk94 avatar Dec 07 '15 20:12 frnk94

By the way MenuItem is deprecated for now use var MenuItem = require('material-ui/lib/menus/menu-item');

frnk94 avatar Dec 07 '15 20:12 frnk94

By the way you can view the src of each doc components here: https://github.com/callemall/material-ui/tree/master/docs/src/app/components/pages/components

frnk94 avatar Dec 07 '15 20:12 frnk94

@frnk94 thank you so much!

vmaudgalya avatar Dec 07 '15 20:12 vmaudgalya

@frnk94 and to anyone else who may look at this issue in the future

var injectTapEventPlugin = require("react-tap-event-plugin");
injectTapEventPlugin();

were required to make this work. In addition, I understand that MenuItem is deprecated, upon looking into the material-ui index.js file, on changing

  MenuItem: require('./menu/menu-item'),

to

MenuItem: require('./menus/menu-item'),

This import:

import { AppBar, IconButton, IconMenu, MenuItem } from 'material-ui'

worked. Is this a bug or is this intended (because MenuItem is deprecated) ?

vmaudgalya avatar Dec 07 '15 21:12 vmaudgalya

Is this a bug or is this intended (because MenuItem is deprecated) ?

It's not intended, have a look at https://github.com/callemall/material-ui/pull/2307 for more details.

oliviertassinari avatar Dec 07 '15 21:12 oliviertassinari

@oliviertassinari thank you. I also was not aware that import imported all of the components in index.js, I simply used it over require because it made the code cleaner.

I would be more than happy to contribute to material-ui documentation on material-ui.com to assist in keeping the documentation up-to-date :smiley:

vmaudgalya avatar Dec 07 '15 21:12 vmaudgalya

to assist in keeping the documentation up-to-date

Well, we are updating the way we render the documentation. This is a work in progress. For instance

  • appbar: done
  • avatar https://github.com/callemall/material-ui/pull/2407
  • toolbar https://github.com/callemall/material-ui/pull/2415

If you want to work on a specific component, feed free to do it, this would help a lot :+1:!

oliviertassinari avatar Dec 07 '15 21:12 oliviertassinari

@oliviertassinari this is great news to hear, happy to see the documentation moving in the right direction! One last comment - is this intended? screen shot 2015-12-07 at 1 23 27 pm

vmaudgalya avatar Dec 07 '15 21:12 vmaudgalya

This issue is already solved. :tada:

On Mon, 7 Dec 2015, 22:25 Varun Maudgalya [email protected] wrote:

@oliviertassinari https://github.com/oliviertassinari this is great news to hear, happy to see the documentation moving in the right direction! One last comment - is this intended? [image: screen shot 2015-12-07 at 1 23 27 pm] https://cloud.githubusercontent.com/assets/12266146/11640142/e1a955ec-9ce5-11e5-9b69-1223d779ae60.png

— Reply to this email directly or view it on GitHub https://github.com/callemall/material-ui/issues/2414#issuecomment-162668496 .

oliviertassinari avatar Dec 07 '15 21:12 oliviertassinari

@oliviertassinari I'm still seeing it.

calbertts avatar Dec 13 '15 20:12 calbertts

Yes, that's because this issue is fixed on the master branch. But the doc site is reflecting the 0.13.4 version.

oliviertassinari avatar Dec 13 '15 20:12 oliviertassinari

ES6 way to do this would be :

import MoreVert from 'material-ui/svg-icons/navigation/more-vert';

and using the component:

<IconMenu {...props} iconButtonElement={<IconButton><MoreVert/></IconButton>} targetOrigin={{ horizontal: 'right', vertical: 'top' }}

tomgron avatar Jan 12 '17 20:01 tomgron

@tomgron Please don't resurrect long closed issues with stray comments - it spams the maintainers.

mbrookes avatar Jan 13 '17 18:01 mbrookes