Skip to content

Commit d3434f2

Browse files
committed
fix #1025
1 parent e760043 commit d3434f2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/filters/Select.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ class SelectFilter extends Component {
1212
};
1313
}
1414

15+
componentWillReceiveProps(nextProps) {
16+
const isPlaceholderSelected = (nextProps.defaultValue === undefined ||
17+
!nextProps.options.hasOwnProperty(nextProps.defaultValue));
18+
this.setState({
19+
isPlaceholderSelected
20+
});
21+
}
22+
23+
componentDidUpdate(prevProps) {
24+
let needFilter = false;
25+
if (this.props.defaultValue !== prevProps.defaultValue) {
26+
needFilter = true;
27+
} else if (this.props.options !== prevProps.options) {
28+
needFilter = true;
29+
}
30+
if (needFilter) {
31+
const value = this.refs.selectInput.value;
32+
if (value) {
33+
this.props.filterHandler(value, Const.FILTER_TYPE.SELECT);
34+
}
35+
}
36+
}
37+
1538
filter(event) {
1639
const { value } = event.target;
1740
this.setState({ isPlaceholderSelected: (value === '') });

0 commit comments

Comments
 (0)