Skip to content
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

Migrate BasePreRenderer to PressableWithoutFeedback #19083

Merged
merged 5 commits into from
May 29, 2023
Merged
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
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 @@ -1376,6 +1376,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 @@ -1842,6 +1842,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