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

Added Disabled Prop and Styles to DropDownMenu #1406

Merged
merged 3 commits into from
Aug 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -83,6 +83,12 @@ class DropDownMenuPage extends React.Component {
type: 'object',
header: 'optional',
desc: 'Overrides the inline-styles of DropDownMenu\'s root element.'
},
{
name: 'disabled',
type: 'bool',
header: 'default: false',
desc: 'Disables the menu.'
}
]
},
Expand Down
11 changes: 8 additions & 3 deletions src/drop-down-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ let DropDownMenu = React.createClass({
displayMember: React.PropTypes.string,
valueMember: React.PropTypes.string,
autoWidth: React.PropTypes.bool,
disabled: React.PropTypes.bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the default value false in getDefaultProps so that it's straightforward?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

onChange: React.PropTypes.func,
menuItems: React.PropTypes.array.isRequired,
menuItemStyle: React.PropTypes.object,
Expand All @@ -36,6 +37,7 @@ let DropDownMenu = React.createClass({
getDefaultProps() {
return {
autoWidth: true,
disabled: false,
valueMember: 'payload',
displayMember: 'text',
};
Expand Down Expand Up @@ -64,6 +66,7 @@ let DropDownMenu = React.createClass({
},

getStyles(){
const {disabled} = this.props;
let zIndex = 5; // As AppBar
let spacing = this.context.muiTheme.spacing;
let accentColor = this.context.muiTheme.component.dropDownMenu.accentColor;
Expand All @@ -78,7 +81,7 @@ let DropDownMenu = React.createClass({
outline: 'none',
},
control: {
cursor: 'pointer',
cursor: disabled ? 'not-allowed' : 'pointer',
position: 'static',
height: '100%',
},
Expand All @@ -102,7 +105,7 @@ let DropDownMenu = React.createClass({
paddingLeft: spacing.desktopGutter,
top: 0,
opacity: 1,
color: this.context.muiTheme.palette.textColor,
color: disabled ? this.context.muiTheme.palette.disabledColor : this.context.muiTheme.palette.textColor,
},
underline: {
borderTop: 'solid 1px ' + accentColor,
Expand Down Expand Up @@ -240,7 +243,9 @@ let DropDownMenu = React.createClass({
},

_onControlClick() {
this.setState({ open: !this.state.open });
if (!this.props.disabled) {
this.setState({ open: !this.state.open });
}
},

_onKeyDown(e) {
Expand Down