Skip to content

Commit

Permalink
Minor fixes with Picker Item with how we treat the value prop
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanshar committed Nov 26, 2020
1 parent 4c47d27 commit 3ad00bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/picker/PickerItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const PickerItem = props => {
} = props;
const context = useContext(PickerContext);
const {migrate, renderItem} = context;
const isSelected = isItemSelected(value, !migrate && _.isObject(context.value) ? context.value.value : context.value);
const isSelected = isItemSelected(value, !migrate && _.isPlainObject(context.value) ? context.value.value : context.value);
const itemLabel = getItemLabel(label, value, props.getItemLabel || context.getItemLabel);
const accessibilityProps = {
accessibilityState: isSelected ? {selected: true} : undefined,
Expand All @@ -54,7 +54,7 @@ const PickerItem = props => {
if (migrate) {
context.onPress(value);
} else {
context.onPress(_.isObject(value) ? value : {value, label: itemLabel});
context.onPress((_.isPlainObject(value) || context.isMultiMode) ? value : {value, label: itemLabel});
}
}, [migrate, value, context.onPress]);

Expand Down
1 change: 1 addition & 0 deletions src/components/picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class Picker extends PureComponent {
migrate,
value,
onPress: mode === Picker.modes.MULTI ? this.toggleItemSelection : this.onDoneSelecting,
isMultiMode: mode === Picker.modes.MULTI,
getItemValue,
getItemLabel,
onSelectedLayout: this.onSelectedItemLayout,
Expand Down

0 comments on commit 3ad00bc

Please sign in to comment.