Skip to content

Commit

Permalink
Allow programmatic opening and closing DropDownMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLeebo committed Oct 21, 2015
1 parent ca207c4 commit 94463f2
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 94463f2

Please sign in to comment.