Commit faec7edc authored by 陈帅's avatar 陈帅 Committed by niko

Fix bug when TagSelectOption is 1 (#336)

parent 687057be
import React from "react"; import React from "react";
export interface AvatarItemProps { export interface AvatarItemProps {
tips: string | React.ReactNode; tips: React.ReactNode;
src: string; src: string;
} }
......
...@@ -39,7 +39,8 @@ class TagSelect extends Component { ...@@ -39,7 +39,8 @@ class TagSelect extends Component {
} }
getAllTags() { getAllTags() {
const { children } = this.props; let { children } = this.props;
children = React.Children.toArray(children);
const checkedTags = children const checkedTags = children
.filter(child => this.isTagSelectOption(child)) .filter(child => this.isTagSelectOption(child))
.map(child => child.props.value); .map(child => child.props.value);
...@@ -86,7 +87,6 @@ class TagSelect extends Component { ...@@ -86,7 +87,6 @@ class TagSelect extends Component {
[styles.hasExpandTag]: expandable, [styles.hasExpandTag]: expandable,
[styles.expanded]: expand, [styles.expanded]: expand,
}); });
return ( return (
<div className={cls} style={style}> <div className={cls} style={style}>
<CheckableTag <CheckableTag
...@@ -97,8 +97,7 @@ class TagSelect extends Component { ...@@ -97,8 +97,7 @@ class TagSelect extends Component {
全部 全部
</CheckableTag> </CheckableTag>
{ {
checkedTags && children checkedTags && React.Children.map(children, (child) => {
.map((child) => {
if (this.isTagSelectOption(child)) { if (this.isTagSelectOption(child)) {
return React.cloneElement(child, { return React.cloneElement(child, {
key: `tag-select-${child.props.value}`, key: `tag-select-${child.props.value}`,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment