-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix URL rendering #6392
Fix URL rendering #6392
Changes from 3 commits
7b72e06
029d09f
b5a7c53
86d6815
78d8e43
b9f8e47
b5ed67b
5ce1b2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import _ from 'underscore'; | ||
import React, {forwardRef} from 'react'; | ||
import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; | ||
import {Pressable} from 'react-native'; | ||
import {Pressable, Text as RNText} from 'react-native'; | ||
import {propTypes, defaultProps} from './pressableWithSecondaryInteractionPropTypes'; | ||
|
||
/** | ||
|
@@ -10,25 +10,28 @@ import {propTypes, defaultProps} from './pressableWithSecondaryInteractionPropTy | |
* @param {Object} props | ||
* @returns {React.Component} | ||
*/ | ||
const PressableWithSecondaryInteraction = props => ( | ||
<Pressable | ||
ref={props.forwardedRef} | ||
onPress={props.onPress} | ||
onPressIn={props.onPressIn} | ||
onLongPress={(e) => { | ||
e.preventDefault(); | ||
ReactNativeHapticFeedback.trigger('selection', { | ||
enableVibrateFallback: true, | ||
}); | ||
props.onSecondaryInteraction(e); | ||
}} | ||
onPressOut={props.onPressOut} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...(_.omit(props, 'onLongPress'))} | ||
> | ||
{props.children} | ||
</Pressable> | ||
); | ||
const PressableWithSecondaryInteraction = (props) => { | ||
const Node = props.inline ? RNText : Pressable; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @parasharrajat I think it might be worth adding a little comment explaining this option here as well. I know you have added the comment to the PropType, but one compact line in here would be handy. Can you please add one? Thank you 🙌 |
||
return ( | ||
<Node | ||
ref={props.forwardedRef} | ||
onPress={props.onPress} | ||
onPressIn={props.onPressIn} | ||
onLongPress={(e) => { | ||
e.preventDefault(); | ||
ReactNativeHapticFeedback.trigger('selection', { | ||
enableVibrateFallback: true, | ||
}); | ||
props.onSecondaryInteraction(e); | ||
}} | ||
onPressOut={props.onPressOut} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...(_.omit(props, 'onLongPress'))} | ||
> | ||
{props.children} | ||
</Node> | ||
); | ||
}; | ||
|
||
PressableWithSecondaryInteraction.propTypes = propTypes; | ||
PressableWithSecondaryInteraction.defaultProps = defaultProps; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,13 +21,22 @@ const propTypes = { | |||||
|
||||||
/** Prevent the default ContextMenu on web/Desktop */ | ||||||
preventDefaultContentMenu: PropTypes.bool, | ||||||
|
||||||
/** Use Text instead of Presable to create inline layout. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB: Typo
Suggested change
|
||||||
* It has few limitations in comparison to Pressable. | ||||||
* | ||||||
* - No support for delayLongPress. | ||||||
* - No support for pressIn and pressOut events. | ||||||
*/ | ||||||
inline: PropTypes.bool, | ||||||
}; | ||||||
|
||||||
const defaultProps = { | ||||||
forwardedRef: () => {}, | ||||||
onPressIn: () => {}, | ||||||
onPressOut: () => {}, | ||||||
preventDefaultContentMenu: true, | ||||||
inline: false, | ||||||
}; | ||||||
|
||||||
export {propTypes, defaultProps}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here