From 94463f2bbb5a8287759f082e112327d87d9d0e26 Mon Sep 17 00:00:00 2001 From: Jeremy Liberman Date: Mon, 21 Sep 2015 09:49:42 -0500 Subject: [PATCH] Allow programmatic opening and closing DropDownMenu --- docs/src/app/components/pages/components/drop-down-menu.jsx | 6 ++++++ src/drop-down-menu.jsx | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/src/app/components/pages/components/drop-down-menu.jsx b/docs/src/app/components/pages/components/drop-down-menu.jsx index 7b7fc2a4051bb8..c3e2e501605bd4 100644 --- a/docs/src/app/components/pages/components/drop-down-menu.jsx +++ b/docs/src/app/components/pages/components/drop-down-menu.jsx @@ -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.', + }, ], }, { diff --git a/src/drop-down-menu.jsx b/src/drop-down-menu.jsx index a46d9da155ac96..610b02a2fe2d94 100644 --- a/src/drop-down-menu.jsx +++ b/src/drop-down-menu.jsx @@ -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() { @@ -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), };