Skip to content

Commit

Permalink
fix(TreeSelect): show all tree while searchValue clear
Browse files Browse the repository at this point in the history
  • Loading branch information
bindoon committed Nov 1, 2018
1 parent bb2acdf commit c04b3d3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/tree-select/tree-select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default class TreeSelect extends Component {
* @param {String} keyword 输入的关键字
*/
onSearch: PropTypes.func,
onSearchClear: PropTypes.func,
/**
* 无数据时显示内容
*/
Expand Down Expand Up @@ -168,6 +169,7 @@ export default class TreeSelect extends Component {
onChange: noop,
showSearch: false,
onSearch: noop,
onSearchClear: noop,
notFoundContent: 'Not Found',
multiple: false,
treeCheckable: false,
Expand All @@ -192,7 +194,7 @@ export default class TreeSelect extends Component {
autoExpandParent: false
};

bindCtx(this, ['handleSelect', 'handleCheck', 'handleSearch', 'handleVisibleChange', 'handleChange', 'handleRemove', 'handleExpand']);
bindCtx(this, ['handleSelect', 'handleCheck', 'handleSearch', 'handleSearchClear', 'handleVisibleChange', 'handleChange', 'handleRemove', 'handleExpand']);

this.updateCache(props);
}
Expand Down Expand Up @@ -422,6 +424,14 @@ export default class TreeSelect extends Component {
this.props.onSearch(searchedValue);
}

handleSearchClear(triggerType) {
this.setState({
searchedValue: '',
expandedKeys: []
});
this.props.onSearchClear(triggerType);
}

handleExpand(expandedKeys) {
this.setState({
expandedKeys,
Expand Down Expand Up @@ -675,6 +685,7 @@ export default class TreeSelect extends Component {
onVisibleChange={this.handleVisibleChange}
showSearch={showSearch}
onSearch={this.handleSearch}
onSearchClear={this.handleSearchClear}
popupContent={this.renderPopupContent()}
popupContainer={popupContainer}
popupStyle={popupStyle}
Expand Down

0 comments on commit c04b3d3

Please sign in to comment.