Skip to content

Commit 4be6484

Browse files
committed
fix: renderButtonText not work on select(idx)
1 parent f7c1ada commit 4be6484

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

components/ModalDropdown.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ export default class ModalDropdown extends Component {
137137
}
138138

139139
select(idx) {
140-
let value = this.props.defaultValue;
141-
if (idx == null || this.props.options == null || idx >= this.props.options.length) {
142-
idx = this.props.defaultIndex;
140+
const {defaultValue, options, defaultIndex, renderButtonText} = this.props;
141+
142+
let value = defaultValue;
143+
if (idx == null || !options || idx >= options.length) {
144+
idx = defaultIndex;
143145
}
144146

145147
if (idx >= 0) {
146-
value = this.props.options[idx].toString();
148+
value = renderButtonText ? renderButtonText(options[idx]) : options[idx].toString();
147149
}
148150

149151
this._nextValue = value;

0 commit comments

Comments
 (0)