Skip to content

Commit

Permalink
Forward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
warmhug committed May 20, 2016
1 parent 627c367 commit b993c20
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ online example: http://react-component.github.io/tree-select/
|maxTagTextLength | max tag text length to show | number | - |
|multiple | whether multiple select (true when enable treeCheckable) | bool | false |
|disabled | whether disabled select | bool | false |
|inputValue | if enable search, you can set default input's value | string | - |
|inputValue | if enable search, you can set default input's value, if set to null, auto clear input value when finish select/unselect operation | string/null | '' |
|defaultValue | initial selected treeNode(s) | same as value type | - |
|value | current selected treeNode(s). | normal: String/Array<String>. labelInValue: {value:String,label:React.Node}/Array<{value,label}>. treeCheckStrictly(halfChecked default false): {value:String,label:React.Node, halfChecked}/Array<{value,label,halfChecked}>. | - |
|labelInValue| whether to embed label in value, see above value type | Bool | false |
Expand Down
2 changes: 1 addition & 1 deletion examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const Demo = React.createClass({
placeholder={<i>请下拉选择</i>}
searchPlaceholder="please search"
treeLine maxTagTextLength={10}
inputValue={'0-2'}
inputValue={null}
value={this.state.value}
treeData={gData}
treeNodeFilterProp="title"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-tree-select",
"version": "1.7.0",
"version": "1.7.1",
"description": "tree-select ui component for react",
"keywords": [
"react",
Expand Down
29 changes: 18 additions & 11 deletions src/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Select = React.createClass({
onSearch: PropTypes.func,
searchPlaceholder: PropTypes.string,
placeholder: PropTypes.any,
inputValue: PropTypes.string,
inputValue: PropTypes.any,
value: PropTypes.oneOfType([PropTypes.array, PropTypes.string, PropTypes.object]),
defaultValue: PropTypes.oneOfType([PropTypes.array, PropTypes.string, PropTypes.object]),
label: PropTypes.any,
Expand Down Expand Up @@ -145,7 +145,7 @@ const Select = React.createClass({
this.renderedTreeData = this.renderTreeData();
value = this.addLabelToValue(props, value);
value = this.getValue(props, value);
const inputValue = props.inputValue;
const inputValue = props.inputValue || '';
// if (props.combobox) {
// inputValue = value.length ? String(value[0].value) : '';
// }
Expand Down Expand Up @@ -384,9 +384,11 @@ const Select = React.createClass({
}

this.fireChange(value, extraInfo);
// this.setState({
// inputValue: '',
// });
if (props.inputValue === null) {
this.setState({
inputValue: '',
});
}
// if (isCombobox(props)) {
// this.setState({
// inputValue: getPropValue(item, props.treeNodeLabelProp),
Expand All @@ -399,9 +401,11 @@ const Select = React.createClass({
if (!isMultipleOrTags(this.props)) {
this.setOpenState(false);
}
// this.setState({
// inputValue: '',
// });
if (this.props.inputValue === null) {
this.setState({
inputValue: '',
});
}
},

onPlaceholderClick() {
Expand Down Expand Up @@ -432,9 +436,11 @@ const Select = React.createClass({
if (state.inputValue || state.value.length) {
this.fireChange([]);
this.setOpenState(false);
// this.setState({
// inputValue: '',
// });
if (props.inputValue === null) {
this.setState({
inputValue: '',
});
}
}
},

Expand Down Expand Up @@ -878,6 +884,7 @@ const Select = React.createClass({
disabled={disabled}
visible={state.open}
inputValue={state.inputValue}
_inputValue={props.inputValue === null}
inputElement={this.getInputElement()}
value={state.value}
onDropdownVisibleChange={this.onDropdownVisibleChange}
Expand Down
3 changes: 2 additions & 1 deletion src/SelectTrigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const SelectTrigger = React.createClass({
filterTreeNode: PropTypes.any,
treeNodes: PropTypes.any,
inputValue: PropTypes.string,
_inputValue: PropTypes.bool,
prefixCls: PropTypes.string,
popupClassName: PropTypes.string,
children: PropTypes.any,
Expand Down Expand Up @@ -175,7 +176,7 @@ const SelectTrigger = React.createClass({
};

if (props.treeCheckable) {
if (!props.inputValue) {
if (!props.inputValue || props._inputValue) {
trProps._treeNodesStates = props._treeNodesStates;
}
trProps.selectable = false;
Expand Down

0 comments on commit b993c20

Please sign in to comment.