Skip to content

Commit

Permalink
Merge pull request #19083 from robertKozik/17007-migrate-BasePreRenderer
Browse files Browse the repository at this point in the history
Migrate BasePreRenderer to PressableWithoutFeedback
  • Loading branch information
techievivek authored May 29, 2023
2 parents 7bf0763 + 857df4b commit 0c44fed
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, {forwardRef} from 'react';
import {ScrollView} from 'react-native-gesture-handler';
import {TouchableWithoutFeedback, View} from 'react-native';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import htmlRendererPropTypes from '../htmlRendererPropTypes';
import withLocalize from '../../../withLocalize';
import {ShowContextMenuContext, showContextMenuForReport} from '../../../ShowContextMenuContext';
import styles from '../../../../styles/styles';
import * as ReportUtils from '../../../../libs/ReportUtils';
import PressableWithoutFeedback from '../../../Pressable/PressableWithoutFeedback';

const propTypes = {
/** Press in handler for the code block */
Expand Down Expand Up @@ -37,16 +38,18 @@ const BasePreRenderer = forwardRef((props, ref) => {
>
<ShowContextMenuContext.Consumer>
{({anchor, report, action, checkIfContextMenuActive}) => (
<TouchableWithoutFeedback
<PressableWithoutFeedback
onPressIn={props.onPressIn}
onPressOut={props.onPressOut}
onLongPress={(event) => showContextMenuForReport(event, anchor, report.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
accessibilityRole="text"
accessibilityLabel={props.translate('accessibilityHints.prestyledText')}
>
<View>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
<TDefaultRenderer {...defaultRendererProps} />
</View>
</TouchableWithoutFeedback>
</PressableWithoutFeedback>
)}
</ShowContextMenuContext.Consumer>
</ScrollView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ const GenericPressable = forwardRef((props, ref) => {
if (isDisabled) {
return;
}
if (!onPress) {
return;
}
if (shouldUseHapticsOnPress) {
HapticFeedback.press();
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Pressable/GenericPressable/PropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const pressablePropTypes = {
/**
* onPress callback
*/
onPress: PropTypes.func.isRequired,
onPress: PropTypes.func,

/**
* Specifies keyboard shortcut to trigger onPressHandler
Expand Down Expand Up @@ -121,6 +121,7 @@ const pressablePropTypes = {
};

const defaultProps = {
onPress: undefined,
keyboardShortcut: undefined,
shouldUseHapticsOnPress: false,
shouldUseHapticsOnLongPress: false,
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ export default {
workspaceName: 'Workspace name',
chatUserDisplayNames: 'Chat user display names',
scrollToNewestMessages: 'Scroll to newest messages',
prestyledText: 'Prestyled text',
},
parentReportAction: {
deletedMessage: '[Deleted message]',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,7 @@ export default {
workspaceName: 'Nombre del espacio de trabajo',
chatUserDisplayNames: 'Nombres de los usuarios del chat',
scrollToNewestMessages: 'Desplázate a los mensajes más recientes',
prestyledText: 'texto preestilizado',
},
parentReportAction: {
deletedMessage: '[Mensaje eliminado]',
Expand Down

0 comments on commit 0c44fed

Please sign in to comment.