Fix allowClear of TreeSelect, close #1084

This commit is contained in:
afc163 2016-02-26 17:12:56 +08:00
parent 7ea67b6e37
commit d2cf85b87b
4 changed files with 38 additions and 42 deletions

View File

@ -26,6 +26,7 @@ const Demo = React.createClass({
value={this.state.value} value={this.state.value}
dropdownMenuStyle={{ maxHeight: 400, overflow: 'auto' }} dropdownMenuStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="请选择" placeholder="请选择"
allowClear
treeDefaultExpandAll treeDefaultExpandAll
onChange={this.onChange}> onChange={this.onChange}>
<TreeNode value="parent 1" title="parent 1" key="0-1"> <TreeNode value="parent 1" title="parent 1" key="0-1">

View File

@ -1,7 +1,6 @@
import React from 'react'; import React from 'react';
import TreeSelect, { TreeNode } from 'rc-tree-select'; import TreeSelect, { TreeNode } from 'rc-tree-select';
import classNames from 'classnames'; import classNames from 'classnames';
// import animation from '../common/openAnimation';
const AntTreeSelect = React.createClass({ const AntTreeSelect = React.createClass({
getDefaultProps() { getDefaultProps() {
@ -10,7 +9,6 @@ const AntTreeSelect = React.createClass({
transitionName: 'slide-up', transitionName: 'slide-up',
choiceTransitionName: 'zoom', choiceTransitionName: 'zoom',
showSearch: false, showSearch: false,
// openAnimation: animation,
}; };
}, },
render() { render() {

View File

@ -4,6 +4,37 @@
@import "../mixins/iconfont"; @import "../mixins/iconfont";
.selection__clear() {
display: inline-block;
font-style: normal;
vertical-align: baseline;
text-align: center;
text-transform: none;
text-rendering: auto;
opacity: 0;
position: absolute;
right: 8px;
z-index: 1;
background: #fff;
top: 50%;
font-size: 12px;
color: #ccc;
width: 12px;
height: 12px;
margin-top: -6px;
line-height: 12px;
cursor: pointer;
transition: color 0.3s ease, opacity 0.15s ease;
&:before {
display: block;
font-family: "anticon" !important;
content: "\E631";
}
&:hover {
color: #999;
}
}
.@{select-prefix-cls} { .@{select-prefix-cls} {
box-sizing: border-box; box-sizing: border-box;
display: inline-block; display: inline-block;
@ -53,39 +84,13 @@
&:hover { &:hover {
.hover; .hover;
} }
&:active { &:active {
.active; .active;
} }
&__clear { &__clear {
display: inline-block; .selection__clear();
font-style: normal;
vertical-align: baseline;
text-align: center;
text-transform: none;
text-rendering: auto;
opacity: 0;
position: absolute;
right: 8px;
z-index: 1;
background: #fff;
top: 50%;
font-size: 12px;
color: #ccc;
width: 12px;
height: 12px;
margin-top: -6px;
line-height: 12px;
cursor: pointer;
transition: color 0.3s ease, opacity 0.15s ease;
&:before {
display: block;
font-family: "anticon" !important;
content: "\E631";
}
&:hover {
color: #999;
}
} }
&:hover &__clear { &:hover &__clear {

View File

@ -115,12 +115,6 @@
@duration: .3s; @duration: .3s;
@import "../mixins/iconfont"; @import "../mixins/iconfont";
//mixin
.selection__clear() {
cursor: pointer;
float: right;
font-weight: bold;
}
.@{tree-select-prefix-cls} { .@{tree-select-prefix-cls} {
box-sizing: border-box; box-sizing: border-box;
@ -216,6 +210,10 @@
.selection__clear(); .selection__clear();
} }
&:hover .@{tree-select-prefix-cls}-selection__clear {
opacity: 1;
}
.@{tree-select-prefix-cls}-selection__placeholder { .@{tree-select-prefix-cls}-selection__placeholder {
color: #ccc; color: #ccc;
} }
@ -345,12 +343,6 @@
padding-bottom: 4px; padding-bottom: 4px;
} }
.@{tree-select-prefix-cls}-selection__clear {
.selection__clear();
margin-top: 5px;
margin-right: 10px;
}
> ul > li { > ul > li {
margin-top: 4px; margin-top: 4px;
height: 20px; height: 20px;