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

Fixed menu height doesn't allow re-rendering with different menu items #203

Closed
tschaub opened this issue Jan 6, 2015 · 7 comments
Closed
Labels
component: menu This is the name of the generic UI component, not the React module!

Comments

@tschaub
Copy link
Contributor

tschaub commented Jan 6, 2015

Because the menu height is calculated once and cached, if a dropdown menu component is re-rendered with a different set of menuItems, its height will be invalid.

Here is a sample dropdown that attempts to render lazily loaded items:

var React = require('react');
var mui = require('material-ui');

var items = [
  {text: 'First'},
  {text: 'Second'},
  {text: 'Third'}
];

var DropDownTest = React.createClass({

  getInitialState: function() {
    return {
      items: [{text: 'Loading items ...'}]
    };
  },

  componentDidMount: function() {
    setTimeout(this._onLoad, 2000);
  },

  render: function() {
    return (
      <mui.DropDownMenu menuItems={this.state.items}/>
    );
  },

  _onLoad: function(items) {
    this.setState({
      items: items
    });
  }

});

module.exports = DropDownTest;
@arathunku
Copy link

This is so annoying.

I've changed

        el.style.height = this._initialMenuHeight + 'px';

to:

        el.style.height = 'initial';

in src/js/menu.jsx and I'm still experimenting with it but so far works without problem in my case. Do you think I should submit PR with it?

@hai-cea
Copy link
Member

hai-cea commented Jan 14, 2015

The height is saved so that we can perform a height transition on the container. This is actually an expensive property to animate and comes with a performance cost. Maybe we should just remove this and use transform scale instead?

@pola88
Copy link

pola88 commented Jan 29, 2015

Hi guys,

I have the same problem, Did you find the way to do this?

Thanks in advance,

motiz88 added a commit to motiz88/material-ui that referenced this issue Mar 11, 2015
@bytesandwich
Copy link

I hard coded the same change as @arathunku and it makes the broken drop down menu (on css-in-js 2f1d412) work for me.

@hai-cea
Copy link
Member

hai-cea commented Jun 3, 2015

Fixed with #544

@hai-cea hai-cea closed this as completed Jun 3, 2015
@jtdaugherty
Copy link

I just ran into this same problem in 0.7.5 and I'm curious to know when this patch will make it into, say, 0.8.1. (CC @travitch)

@jtdaugherty
Copy link

(Or, better yet, a bugfix release, 0.7.6.)

@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 25, 2022
@zannager zannager added component: menu This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 16, 2023
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