Skip to content

Commit 5930ea5

Browse files
mendyEdriethanshar
andauthored
Fix/picker get label (#1059)
* removed redundant logic, changes are made onChange event * Fix getLabel property issue on multi-select mode Co-authored-by: Ethan Sharabi <[email protected]>
1 parent a8cb278 commit 5930ea5

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/components/picker/index.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,9 @@ class Picker extends PureComponent {
227227
};
228228
};
229229

230-
shouldNotChangePickerLabelWhileSelecting = () => {
231-
const {mode} = this.props;
232-
return mode === Picker.modes.MULTI;
233-
};
234-
235230
getLabelValueText = () => {
236-
const {value: propsValue} = this.props;
237-
const {value: stateValue} = this.props;
238-
239-
if (this.shouldNotChangePickerLabelWhileSelecting()) {
240-
return this.getLabel(propsValue);
241-
}
242-
return this.getLabel(stateValue);
231+
const {value} = this.props;
232+
return this.getLabel(value);
243233
};
244234

245235
getLabelsFromArray = value => {
@@ -256,14 +246,14 @@ class Picker extends PureComponent {
256246
getLabel(value) {
257247
const {getLabel} = this.props;
258248

249+
if (_.isFunction(getLabel) && !_.isUndefined(getLabel(value))) {
250+
return getLabel(value);
251+
}
252+
259253
if (_.isArray(value)) {
260254
return this.getLabelsFromArray(value);
261255
}
262256

263-
if (_.isFunction(getLabel)) {
264-
return getLabel(value);
265-
}
266-
267257
if (_.isPlainObject(value)) {
268258
return _.get(value, 'label');
269259
}

0 commit comments

Comments
 (0)