Skip to content

Picker - add onItemPress #2786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

M-i-k-e-l
Copy link
Collaborator

Description

Picker - add onItemPress
Relates to the FontPicker

Changelog

Picker - add onItemPress

Additional info

None

@M-i-k-e-l M-i-k-e-l added the Important for Next Release PR that must be included in the release version label Oct 31, 2023
@M-i-k-e-l M-i-k-e-l added this to the Design Kits milestone Oct 31, 2023
@M-i-k-e-l M-i-k-e-l requested a review from ethanshar October 31, 2023 06:39
/**
* A callback to be used when an item has been pressed, will stop selection if false is returned
*/
onItemPress?: (item: PickerValue) => Promise<boolean>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming people dont need onItemPress to be asynchronous, typing wise they will still need to return a promise and that can be annoying, no?
if my logic is synchronous, TS won't complain?

const onDoneSelecting = useCallback((item: PickerValue) => {
const onDoneSelecting = useCallback(async (item: PickerValue) => {
// Using !(await onItemPress?.(item)) does not work properly when onItemPress is not sent
if (onItemPress && !(await onItemPress(item))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have an onPress callback in PickerItemProps, do you think we should use that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other way I found to do this is shown in another PR, you choose

@M-i-k-e-l M-i-k-e-l closed this Oct 31, 2023
@M-i-k-e-l M-i-k-e-l deleted the feat/picker-add-on-item-press branch October 31, 2023 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Important for Next Release PR that must be included in the release version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants