Skip to content

Commit 3ad00bc

Browse files
committed
Minor fixes with Picker Item with how we treat the value prop
1 parent 4c47d27 commit 3ad00bc

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/components/picker/PickerItem.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const PickerItem = props => {
3030
} = props;
3131
const context = useContext(PickerContext);
3232
const {migrate, renderItem} = context;
33-
const isSelected = isItemSelected(value, !migrate && _.isObject(context.value) ? context.value.value : context.value);
33+
const isSelected = isItemSelected(value, !migrate && _.isPlainObject(context.value) ? context.value.value : context.value);
3434
const itemLabel = getItemLabel(label, value, props.getItemLabel || context.getItemLabel);
3535
const accessibilityProps = {
3636
accessibilityState: isSelected ? {selected: true} : undefined,
@@ -54,7 +54,7 @@ const PickerItem = props => {
5454
if (migrate) {
5555
context.onPress(value);
5656
} else {
57-
context.onPress(_.isObject(value) ? value : {value, label: itemLabel});
57+
context.onPress((_.isPlainObject(value) || context.isMultiMode) ? value : {value, label: itemLabel});
5858
}
5959
}, [migrate, value, context.onPress]);
6060

src/components/picker/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class Picker extends PureComponent {
213213
migrate,
214214
value,
215215
onPress: mode === Picker.modes.MULTI ? this.toggleItemSelection : this.onDoneSelecting,
216+
isMultiMode: mode === Picker.modes.MULTI,
216217
getItemValue,
217218
getItemLabel,
218219
onSelectedLayout: this.onSelectedItemLayout,

0 commit comments

Comments
 (0)