Skip to content

Commit

Permalink
fix(Cascader): keyboard not blur
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Dec 20, 2018
1 parent ab78950 commit 3e43e6a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/cascader/cascader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class Cascader extends Component {
*/
loadData: PropTypes.func,
searchValue: PropTypes.string,
onBlur: PropTypes.func,
filteredPaths: PropTypes.array,
filteredListStyle: PropTypes.object,
resultRender: PropTypes.func
Expand Down Expand Up @@ -148,7 +149,7 @@ export default class Cascader extends Component {

this.lastExpandedValue = [...this.state.expandedValue];

bindCtx(this, ['handleMouseLeave', 'handleFocus', 'handleFold', 'getCascaderNode']);
bindCtx(this, ['handleMouseLeave', 'handleFocus', 'handleFold', 'getCascaderNode', 'onBlur']);
}

componentDidMount() {
Expand Down Expand Up @@ -557,13 +558,21 @@ export default class Cascader extends Component {
return indeterminate;
}

onBlur(e) {
this.setState({
focusedValue: ''
});

this.props.onBlur && this.props.onBlur(e);
}

renderMenu(data, level) {
const { prefix, multiple, useVirtual, checkStrictly, expandTriggerType, loadData,
canOnlyCheckLeaf, listClassName, listStyle, itemRender } = this.props;
const { value, expandedValue, focusedValue } = this.state;

return (
<CascaderMenu key={level} prefix={prefix} useVirtual={useVirtual} className={listClassName} style={listStyle} focusedKey={focusedValue} onItemFocus={this.handleFocus}>
<CascaderMenu key={level} prefix={prefix} useVirtual={useVirtual} className={listClassName} style={listStyle} focusedKey={focusedValue} onItemFocus={this.handleFocus} onBlur={this.onBlur}>
{data.map(item => {
const disabled = !!item.disabled;
const canExpand = (!!item.children && !!item.children.length) || (!!loadData && !item.isLeaf);
Expand Down

0 comments on commit 3e43e6a

Please sign in to comment.