ElemeFE / ElemeFE/element-react

Select cannot query when it has filterMethod prop.

Open
#982 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.8k
Forks
435
PR merge metrics
No merged PRs in 30d

Description

### Description

当Select上有filterMethod时, 输入框输入异常。

### Reproduce Steps
如图所示,按一次 删除键,删除的内容会被置回来。

![jpxtp-bhw4a](https://user-images.githubusercontent.com/12878132/57504562-8c85ab80-7327-11e9-86b5-ee065cb12223.gif)

### 复现代码
```js
constructor(props) {
super(props);

this.state = {
options: this.getDefaultOptions(),
value: {
value: 'aaaa',
label: 'aaaa'
}
};
this.handleInput = this.handleInput.bind(this);
this.handleFilter = this.handleFilter.bind(this);
}

handleFilter(query) {
const allOptions = this.getDefaultOptions();
const options = query && query !== this.state.value.label
? allOptions.filter(item => item.label.toLowerCase().includes(query.toLowerCase()))
: allOptions;
this.setState({ options });
}

getDefaultOptions() {
return [{
value: 'aaaa',
label: 'aaaa'
}, {
value: 'aabb',
label: 'aabb'
}, {
value: 'bbbb',
label: 'bbbb'
}, {
value: 'bbcc',
label: 'bbcc'
}, {
value: 'cccc',
label: 'cccc'
}];
}

handleInput(selectedValue) {
const allOptions = this.getDefaultOptions();
const value = allOptions.find(item => item.value === selectedValue);
this.setState({ value });
console.log(value);
}

render() {
return (

{
this.state.options.map(el => {
return
})
}

)
}
```

### Error Trace (if possible)

### Solution

### Additional Information

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.