Skip to content

Commit

Permalink
fix(Select): option click handler
Browse files Browse the repository at this point in the history
  • Loading branch information
bushuai committed Dec 24, 2020
1 parent 6f78275 commit 3cc1e55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions source/components/Select/Option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class Option extends React.Component<OptionProps> {

onOptionClick = (e: React.MouseEvent<any>, option) => {
const { disabled, onOptionClick } = this.props;

if (!disabled) {
onOptionClick && onOptionClick(e, option);
}
Expand Down
6 changes: 3 additions & 3 deletions source/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,10 @@ class Select extends React.Component<SelectProps, SelectState> {
};

//获取加料后的children
getProcessedChildren = (children, dropdownCls) => {
getProcessedChildren = (children, dropdownCls: string) => {
return React.Children.map(children, (child: any) => {
const typeOfChildren = Object.prototype.toString.call(child).slice(8, -1).toLowerCase();
if (!!child && typeOfChildren === 'object' && child.isSelectOption) {
if (!!child && typeOfChildren === 'object' && child.type.isSelectOption) {
const { selectValue, activeKey } = this.state;
const { showOptionCheckedIcon } = this.props;
const value = 'value' in child.props ? child.props.value : child.key;
Expand All @@ -526,7 +526,7 @@ class Select extends React.Component<SelectProps, SelectState> {
ref: value,
children: this.getProcessedChildren(child.props.children, dropdownCls)
});
} else if (!!child && typeOfChildren === 'object' && child.isSelectOptGroup) {
} else if (!!child && typeOfChildren === 'object' && child.type.isSelectOptGroup) {
return React.cloneElement(child, {
prefixCls: `${dropdownCls}-option-group`,
children: this.getProcessedChildren(child.props.children, dropdownCls)
Expand Down

0 comments on commit 3cc1e55

Please sign in to comment.