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

Fix that clicking on the trip preview component doesn’t open the trip #55972

Merged
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
21 changes: 15 additions & 6 deletions src/components/ReportActionItem/TripRoomPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ type TripRoomPreviewProps = {

type ReservationViewProps = {
reservation: Reservation;
onPress?: () => void;
};

function ReservationView({reservation}: ReservationViewProps) {
function ReservationView({reservation, onPress}: ReservationViewProps) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand Down Expand Up @@ -102,7 +103,8 @@ function ReservationView({reservation}: ReservationViewProps) {
wrapperStyle={[styles.taskDescriptionMenuItem, styles.p0]}
shouldGreyOutWhenDisabled={false}
numberOfLinesTitle={0}
interactive={false}
shouldRemoveBackground
onPress={onPress}
iconHeight={variables.iconSizeSmall}
iconWidth={variables.iconSizeSmall}
iconStyles={[StyleUtils.getTripReservationIconContainer(true), styles.mr3]}
Expand All @@ -111,8 +113,6 @@ function ReservationView({reservation}: ReservationViewProps) {
);
}

const renderItem = ({item}: ListRenderItemInfo<ReservationData>) => <ReservationView reservation={item.reservation} />;

function TripRoomPreview({action, chatReportID, containerStyles, contextMenuAnchor, isHovered = false, checkIfContextMenuActive = () => {}}: TripRoomPreviewProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand All @@ -136,6 +136,14 @@ function TripRoomPreview({action, chatReportID, containerStyles, contextMenuAnch
);
}, [currency, totalDisplaySpend, tripTransactions]);

const navigateToTrip = () => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chatReportID));
const renderItem = ({item}: ListRenderItemInfo<ReservationData>) => (
<ReservationView
reservation={item.reservation}
onPress={navigateToTrip}
/>
);

return (
<OfflineWithFeedback
pendingAction={action?.pendingAction}
Expand All @@ -144,11 +152,12 @@ function TripRoomPreview({action, chatReportID, containerStyles, contextMenuAnch
>
<View style={[styles.chatItemMessage, containerStyles]}>
<PressableWithoutFeedback
onPress={navigateToTrip}
onPressIn={() => canUseTouchScreen() && ControlSelection.block()}
onPressOut={() => ControlSelection.unblock()}
onLongPress={(event) => showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive)}
shouldUseHapticsOnLongPress
style={[styles.flexRow, styles.justifyContentBetween, styles.reportPreviewBox, styles.cursorDefault]}
style={[styles.flexRow, styles.justifyContentBetween, styles.reportPreviewBox]}
role={CONST.ROLE.BUTTON}
accessibilityLabel={translate('iou.viewDetails')}
>
Expand Down Expand Up @@ -184,7 +193,7 @@ function TripRoomPreview({action, chatReportID, containerStyles, contextMenuAnch
<Button
success
text={translate('travel.viewTrip')}
onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chatReportID))}
onPress={navigateToTrip}
/>
</View>
</PressableWithoutFeedback>
Expand Down
Loading