Skip to content

Commit 825189c

Browse files
authored
PickerItem - add onPress support (#2500)
1 parent ccc202e commit 825189c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/components/picker/PickerItem.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const PickerItem = (props: PickerItemProps) => {
2525
disabled,
2626
selectedIcon = Assets.icons.check,
2727
selectedIconColor = Colors.$iconPrimary,
28+
onPress,
2829
testID
2930
} = props;
3031
const context = useContext(PickerContext);
@@ -62,13 +63,14 @@ const PickerItem = (props: PickerItemProps) => {
6263
}, [isItemDisabled, labelStyle]);
6364

6465
const _onPress = useCallback(() => {
66+
onPress?.();
6567
if (migrate) {
6668
context.onPress(value);
6769
} else {
6870
// @ts-expect-error TODO: fix after removing migrate prop completely
6971
context.onPress(typeof value === 'object' || context.isMultiMode ? value : ({value, label: itemLabel}) as PickerSingleValue);
7072
}
71-
}, [migrate, value, context.onPress]);
73+
}, [migrate, value, context.onPress, onPress]);
7274

7375
const onSelectedLayout = useCallback((...args: any[]) => {
7476
_.invoke(context, 'onSelectedLayout', ...args);

src/components/picker/api/pickerItem.api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{"name": "selectedIcon", "type": "string", "description": "Pass to change the selected icon"},
2424
{"name": "selectedIconColor", "type": "ImageSource", "description": "Pass to change the selected icon color"},
2525
{"name": "disabled", "type": "boolean", "description": "Is the item disabled"},
26-
{"name": "onPress", "type": "(value: string | number) => void", "description": "Callback for onPress action"},
26+
{"name": "onPress", "type": "() => void", "description": "Callback for onPress action"},
2727
{
2828
"name": "onSelectedLayout",
2929
"type": "(event: LayoutChangeEvent) => void",

0 commit comments

Comments
 (0)