Skip to content

Comments

feat: add onPressIn, onPressOut, onHoverIn, onHoverOut to FAB and Button#3750

Closed
RichardLindhout wants to merge 1 commit intocallstack:mainfrom
web-ridge:feature/on-press-in-hover
Closed

feat: add onPressIn, onPressOut, onHoverIn, onHoverOut to FAB and Button#3750
RichardLindhout wants to merge 1 commit intocallstack:mainfrom
web-ridge:feature/on-press-in-hover

Conversation

@RichardLindhout
Copy link
Contributor

@RichardLindhout RichardLindhout commented Mar 13, 2023

Summary

The other components like IconButton and ListItem already supports these props as they use Pressable props and spread them.

Fixes: #3748

* Function to execute on press.
*/
onPress?: (e: GestureResponderEvent) => void;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

Copy link
Contributor

@pac-guerreiro pac-guerreiro left a comment

Choose a reason for hiding this comment

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

Left some comments regarding the new types.

Overall, thank you for these new changes with comments describing what functions do 😄

/**
* Called when the hover is activated to provide visual feedback.
*/
onHoverIn?: (e: MouseEvent) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

This type is valid for web but for native the right type is ({nativeEvent: MouseEvent}) => void

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor

@pac-guerreiro pac-guerreiro Apr 7, 2023

Choose a reason for hiding this comment

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

Then React Native docs are outdated -> https://reactnative.dev/docs/pressable#onhoverin

/**
* Called when the hover is deactivated to undo visual feedback.
*/
onHoverOut?: (e: MouseEvent) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

This type is valid for web but for native the right type is ({nativeEvent: MouseEvent}) => void

* Function to execute on long press.
*/
onLongPress?: () => void;
onLongPress?: (e: GestureResponderEvent) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the web docs, the current type is the correct type for web.

For native the right type is ({nativeEvent: PressEvent}) => void

@@ -88,14 +89,30 @@ export type Props = $RemoveChildren<typeof Surface> & {
* Function to execute on press.
*/
onPress?: (e: GestureResponderEvent) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the web docs, the correct type for web is (e: ResponderEvent) => void;.

For native the right type is ({nativeEvent: PressEvent}) => void

/**
* Function to execute as soon as the touchable element is pressed and invoked even before onPress.
*/
onPressIn?: (e: GestureResponderEvent) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the web docs, the correct type for web is (e: ResponderEvent) => void;.

For native the right type is ({nativeEvent: PressEvent}) => void

/**
* Function to execute as soon as the touch is released even before onPress.
*/
onPressOut?: (e: GestureResponderEvent) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the web docs, the correct type for web is (e: ResponderEvent) => void;.

For native the right type is ({nativeEvent: PressEvent}) => void

/**
* Called when the hover is activated to provide visual feedback.
*/
onHoverIn?: (e: MouseEvent) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

This type is valid for web but for native the right type is ({nativeEvent: MouseEvent}) => void

/**
* Called when the hover is deactivated to undo visual feedback.
*/
onHoverOut?: (e: MouseEvent) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

This type is valid for web but for native the right type is ({nativeEvent: MouseEvent}) => void

@web-ridge web-ridge closed this by deleting the head repository Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onMouseEnter & onMouseDown in pressables

5 participants