From e7ed131cecda33b77314fc567da49bf9f1f15dee Mon Sep 17 00:00:00 2001 From: rennerDa Date: Tue, 29 Aug 2017 20:20:59 +0200 Subject: [PATCH 1/2] Changed isPlaceholderSelected check in componentWillReceiveProps IMO there is no need to check for defaultValue here. Just check for current selected value. Maybe this method can be removed, the state for isPlaceholderSelected is updated on every action in this class (f. e. filter, ...). This fixes the github-issue #1568 (https://github.com/AllenFang/react-bootstrap-table/issues/1568) --- src/filters/Select.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filters/Select.js b/src/filters/Select.js index 357660074..214281de8 100644 --- a/src/filters/Select.js +++ b/src/filters/Select.js @@ -24,8 +24,8 @@ class SelectFilter extends Component { } componentWillReceiveProps(nextProps) { - const isPlaceholderSelected = (nextProps.defaultValue === undefined || - !nextProps.options.hasOwnProperty(nextProps.defaultValue)); + const currentSelectValue = this.refs.selectInput.value; + const isPlaceholderSelected = !currentSelectValue || currentSelectValue === ''; this.setState(() => { return { isPlaceholderSelected From 1bba1aaab4d2813f2a60430ec736608eb83bb480 Mon Sep 17 00:00:00 2001 From: rennerDa Date: Tue, 29 Aug 2017 20:26:30 +0200 Subject: [PATCH 2/2] Removed unnecessary and not used parameter nextProps This parameter is not needed anymore. --- src/filters/Select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filters/Select.js b/src/filters/Select.js index 214281de8..b083f2773 100644 --- a/src/filters/Select.js +++ b/src/filters/Select.js @@ -23,7 +23,7 @@ class SelectFilter extends Component { }; } - componentWillReceiveProps(nextProps) { + componentWillReceiveProps() { const currentSelectValue = this.refs.selectInput.value; const isPlaceholderSelected = !currentSelectValue || currentSelectValue === ''; this.setState(() => {