Skip to content

Commit

Permalink
Merge pull request mui#1677 from MrLeebo/open-dropdownmenu
Browse files Browse the repository at this point in the history
Allow programmatic opening and closing DropDownMenu
  • Loading branch information
shaurya947 committed Oct 21, 2015
2 parents 7980cd5 + 94463f2 commit 8c5d095
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/src/app/components/pages/components/drop-down-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ export default class DropDownMenuPage extends React.Component {
header: 'default: false',
desc: 'Disables the menu.',
},
{
name: 'openImmediately',
type: 'bool',
header: 'default: false',
desc: 'Set to true to have the DropDownMenu automatically open on mount.',
},
],
},
{
Expand Down
4 changes: 3 additions & 1 deletion src/drop-down-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const DropDownMenu = React.createClass({
iconStyle:React.PropTypes.object,
labelStyle:React.PropTypes.object,
selectedIndex: React.PropTypes.number,
openImmediately: React.PropTypes.bool,
},

getDefaultProps() {
Expand All @@ -54,12 +55,13 @@ const DropDownMenu = React.createClass({
disabled: false,
valueMember: 'payload',
displayMember: 'text',
openImmediately: false,
};
},

getInitialState() {
return {
open: false,
open: this.props.openImmediately,
selectedIndex: this._isControlled() ? null : (this.props.selectedIndex || 0),
muiTheme: this.context.muiTheme ? this.context.muiTheme : ThemeManager.getMuiTheme(DefaultRawTheme),
};
Expand Down

0 comments on commit 8c5d095

Please sign in to comment.