Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import {
Animated,
GestureResponderEvent,
MouseEvent,
StyleProp,
StyleSheet,
TextStyle,
Expand Down Expand Up @@ -101,6 +102,14 @@ export type Props = React.ComponentProps<typeof Surface> & {
* The number of milliseconds a user must touch the element before executing `onLongPress`.
*/
delayLongPress?: number;
/**
* 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

/**
* Style of button's inner content.
* Use this prop to apply custom height and width and to set the icon on the right with `flexDirection: 'row-reverse'`.
Expand Down Expand Up @@ -176,6 +185,8 @@ const Button = ({
onPress,
onPressIn,
onPressOut,
onHoverOut,
onHoverIn,
onLongPress,
delayLongPress,
style,
Expand Down Expand Up @@ -310,6 +321,8 @@ const Button = ({
onLongPress={onLongPress}
onPressIn={handlePressIn}
onPressOut={handlePressOut}
onHoverIn={onHoverIn}
onHoverOut={onHoverOut}
delayLongPress={delayLongPress}
accessibilityLabel={accessibilityLabel}
accessibilityHint={accessibilityHint}
Expand Down
27 changes: 26 additions & 1 deletion src/components/FAB/FAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AccessibilityState,
Animated,
GestureResponderEvent,
MouseEvent,
StyleProp,
StyleSheet,
View,
Expand Down Expand Up @@ -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

/**
* 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

/**
* The number of milliseconds a user must touch the element before executing `onLongPress`.
*/
delayLongPress?: number;
/**
* 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

/**
* @supported Available in v5.x with theme version 3
*
Expand Down Expand Up @@ -179,6 +196,10 @@ const FAB = forwardRef<View, Props>(
disabled,
onPress,
onLongPress,
onPressIn,
onPressOut,
onHoverOut,
onHoverIn,
delayLongPress,
theme: themeOverrides,
style,
Expand Down Expand Up @@ -279,6 +300,10 @@ const FAB = forwardRef<View, Props>(
borderless
onPress={onPress}
onLongPress={onLongPress}
onPressIn={onPressIn}
onPressOut={onPressOut}
onHoverOut={onHoverOut}
onHoverIn={onHoverIn}
delayLongPress={delayLongPress}
rippleColor={rippleColor}
disabled={disabled}
Expand Down
1 change: 1 addition & 0 deletions src/components/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
* 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

style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
ref?: React.RefObject<View>;
/**
Expand Down