Skip to content

Commit

Permalink
Merge 4d89400 into 59ad5ed
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Oct 11, 2016
2 parents 59ad5ed + 4d89400 commit 4f5f19a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const Select = React.createClass({
]),
dropdownStyle: PropTypes.object,
maxTagTextLength: PropTypes.number,
children: PropTypes.node,
},

mixins: [FilterMixin],
Expand Down Expand Up @@ -211,6 +212,9 @@ const Select = React.createClass({
const value = state.value.concat();
if (value.length) {
const popValue = value.pop();
if (this.getDisabledFromValue(popValue)) {
return;
}
props.onDeselect(props.labelInValue ? popValue : popValue.key);
this.fireChange(value);
}
Expand Down Expand Up @@ -483,6 +487,13 @@ const Select = React.createClass({
return this.refs.trigger.getInnerMenu();
},

getDisabledFromValue(value) {
return toArray(this.props.children).some(child => {
const childValue = getValuePropValue(child);
return childValue === value.key && child.props && child.props.disabled;
});
},

setOpenState(open, needFocus) {
const { props, state } = this;
if (state.open === open) {
Expand Down Expand Up @@ -596,6 +607,7 @@ const Select = React.createClass({
this.setOpenState(true);
}
},

fireChange(value) {
const props = this.props;
if (!('value' in props)) {
Expand Down Expand Up @@ -667,10 +679,7 @@ const Select = React.createClass({
content.length > maxTagTextLength) {
content = `${content.slice(0, maxTagTextLength)}...`;
}
const disabled = toArray(props.children).some(child => {
const childValue = getValuePropValue(child);
return childValue === singleValue.key && child.props && child.props.disabled;
});
const disabled = this.getDisabledFromValue(singleValue);
const choiceClassName = disabled
? `${prefixCls}-selection__choice ${prefixCls}-selection__choice__disabled`
: `${prefixCls}-selection__choice`;
Expand Down

0 comments on commit 4f5f19a

Please sign in to comment.