Skip to content

Commit

Permalink
Added openImmediately
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharlaan committed Oct 12, 2017
1 parent 4ec9703 commit b9bb8da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ This component requires 3 dependencies :
| checkPosition | string | | Position of the checkmark in multiple mode. Accepted values: `'', left, right` |
| canAutoPosition | bool | true | If present, this property allows the inner Popover component to position the menu in such way options are not hidden by the screen edges. |
| multiple | bool | false | Include this property to turn superSelectField into a multi-selection dropdown. Checkboxes will appear.|
| openImmediately | bool | false | Makes the menu opened on page load.|
| disabled | bool | false | Include this property to disable superSelectField.|
| value | null, object, object[] | null | Selected value(s).<br>/!\ REQUIRED: each object must expose a 'value' property. |
| onChange | function | () => {} | Triggers when selecting/unselecting an option from the Menu.<br>signature: (selectedValues, name) with `selectedValues` array of selected values based on selected nodes' value property, and `name` the value of the superSelectField instance's name property |
Expand Down
8 changes: 8 additions & 0 deletions src/SuperSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ class SelectField extends Component {
}
}

componentDidMount () {
// Potential problem with Popover ?
// https://github.com/callemall/material-ui/blob/master/src/DropDownMenu/DropDownMenu.js#L237
if (this.props.openImmediately) this.openMenu()
}

// Counts nodes with non-null value property without optgroups
// noinspection JSMethodCanBeStatic
getChildrenLength (children) {
Expand Down Expand Up @@ -716,6 +722,7 @@ SelectField.propTypes = {
menuCloseButton: PropTypes.node,
canAutoPosition: PropTypes.bool,
multiple: PropTypes.bool,
openImmediately: PropTypes.bool,
disabled: PropTypes.bool,
onChange: PropTypes.func,
onMenuOpen: PropTypes.func,
Expand All @@ -730,6 +737,7 @@ SelectField.defaultProps = {
menuCloseButton: null,
canAutoPosition: true,
multiple: false,
openImmediately: false,
disabled: false,
nb2show: 5,
hintText: 'Click me',
Expand Down

0 comments on commit b9bb8da

Please sign in to comment.