Skip to content

Commit a1c85b9

Browse files
authored
Merge pull request #131 from mrkirchner/renderButtonTextFix
Possible Fix for renderButtonText Not Working
2 parents 9e9982b + 762a920 commit a1c85b9

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

components/ModalDropdown.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ export default class ModalDropdown extends Component {
8585
}
8686

8787
componentWillReceiveProps(nextProps) {
88-
let buttonText = this._nextValue == null ? this.state.buttonText : this._nextValue.toString();
88+
let buttonText = this.state.buttonText;
89+
if (this._nextValue !== null) {
90+
buttonText = nextProps.renderButtonText && nextProps.renderButtonText(this._nextValue) || this._nextValue.toString();
91+
}
8992
let selectedIndex = this._nextIndex == null ? this.state.selectedIndex : this._nextIndex;
9093
if (selectedIndex < 0) {
9194
selectedIndex = nextProps.defaultIndex;
@@ -359,12 +362,8 @@ export default class ModalDropdown extends Component {
359362
this._nextIndex = rowID;
360363
this.setState({
361364
buttonText: renderButtonText && renderButtonText(rowData) || rowData.toString(),
362-
selectedIndex: rowID
363-
});
364-
}
365-
if (!onDropdownWillHide || onDropdownWillHide() !== false) {
366-
this.setState({
367-
showDropdown: false
365+
selectedIndex: rowID,
366+
showDropdown: !(!onDropdownWillHide || onDropdownWillHide() !== false)
368367
});
369368
}
370369
}

0 commit comments

Comments
 (0)