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

DropDownMenu container height not updated while expanded #1145

Merged
merged 1 commit into from
Jul 13, 2015

Conversation

marnusw
Copy link
Contributor

@marnusw marnusw commented Jul 13, 2015

The height of the Paper wrapping the drop-down menu items is calculated based on the number of items in the menu in _expandHideableMenu(), which is in turn called from _renderVisibility(). When the number of menu items changes while the drop-down is open (e.g. showing one item while loading more) this calculated height is not updated, and so the menu items flow out of the container after the re-render.

The problem is that componentDidUpdate() checks for a change in the visible prop before calling _renderVisibility(), but not for a change in the menuItems.length. This is fixed here.

@marnusw
Copy link
Contributor Author

marnusw commented Jul 13, 2015

Hmm, actually, if the labels of the items change without the number of items changing that could still be a problem if autoWidth === true. I'd guess the only way to detect such a case is to compare the text of each menuItem in the old and new menuItems arrays? That will be unfortunate, since it might become a bit expensive on large lists. At least the check is only necessary when autoWidth === true, otherwise it can be skipped (which is the default case). Any thoughts?

@hai-cea
Copy link
Member

hai-cea commented Jul 13, 2015

@marnusw I'm working on a new version of menus that does not need to know the height to transition. You can see a preview for it on IconMenu. I hope to migrate this over to a new component called SelectMenu which will eventually replace DropDownMenu.

Although this is the plan for the near future, I could merge this if it solves an issue you're experiencing?

@marnusw
Copy link
Contributor Author

marnusw commented Jul 13, 2015

Thanks @hai-cea, IconMenu looks really good. Looking forward to see SelectMenu. Is there a specific issue/PR I can subscribe to to stay up to date?

While this is an issue for me at the moment it isn't major, and I'm sure SelectMenu will be ready before we get close to going live with the app, so I'll be switching over in any case. Therefore, not merging this would be OK, although if DropDownMenu will remain as a deprecated component for some time it might still be worth while.

Thanks for your excellent work on this library! 😄

@hai-cea
Copy link
Member

hai-cea commented Jul 13, 2015

Thanks @marnusw Yes, DropDownMenu will be deprecated for some time after SelectMenu is released. I'll go ahead and merge this in for now. Thanks again. 👍

hai-cea added a commit that referenced this pull request Jul 13, 2015
DropDownMenu container height not updated while expanded
@hai-cea hai-cea merged commit b5d0019 into mui:master Jul 13, 2015
@hai-cea
Copy link
Member

hai-cea commented Jul 13, 2015

@marnusw I just created #1158 - Please follow that issue for updates on the new SelectMenu.

@marnusw marnusw deleted the selectHeight branch July 15, 2015 09:30
@zannager zannager added component: menu This is the name of the generic UI component, not the React module! component: Container The React component labels Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Container The React component component: menu This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants