Skip to content

Commit

Permalink
fix: Select's children must be Option or OptGorup, close: #84
Browse files Browse the repository at this point in the history
  • Loading branch information
benjycui committed May 16, 2016
1 parent 51d1834 commit dc25796
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"rc-animate": "2.x",
"rc-menu": "4.x",
"rc-trigger": "1.x",
"rc-util": "3.x"
"rc-util": "3.x",
"warning": "^2.1.0"
},
"pre-commit": [
"lint"
Expand Down
11 changes: 10 additions & 1 deletion src/FilterMixin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import OptGroup from './OptGroup';
import { getValuePropValue, UNSELECTABLE_ATTRIBUTE, UNSELECTABLE_STYLE } from './util';
import { Item as MenuItem, ItemGroup as MenuItemGroup } from 'rc-menu';
import warning from 'warning';
import OptGroup from './OptGroup';
import Option from './Option';

export default {
filterOption(input, child) {
Expand Down Expand Up @@ -44,6 +46,13 @@ export default {
}
return;
}

warning(
child.type === Option,
'the children of `Select` should be `Select.Option` or `Select.OptGroup`, ' +
`instead of \`${child.type.name || child.type.displayName || child.type}\`.`
);

const childValue = getValuePropValue(child);
if (this.filterOption(inputValue, child)) {
sel.push(<MenuItem
Expand Down

0 comments on commit dc25796

Please sign in to comment.