Skip to content

Commit c783c6b

Browse files
Merge pull request #40852 from bernhardoj/fix/40318-prevent-moving-map-when-shown-in-report-preview
Fix map can be moved in money request preview
2 parents c8b4071 + 0d45c55 commit c783c6b

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

src/components/ConfirmedRoute.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ type ConfirmedRoutePropsOnyxProps = {
2626
type ConfirmedRouteProps = ConfirmedRoutePropsOnyxProps & {
2727
/** Transaction that stores the distance expense data */
2828
transaction: OnyxEntry<Transaction>;
29+
30+
/** Whether the map is interactable or not */
31+
interactive?: boolean;
2932
};
3033

31-
function ConfirmedRoute({mapboxAccessToken, transaction}: ConfirmedRouteProps) {
34+
function ConfirmedRoute({mapboxAccessToken, transaction, interactive}: ConfirmedRouteProps) {
3235
const {isOffline} = useNetwork();
3336
const {route0: route} = transaction?.routes ?? {};
3437
const waypoints = transaction?.comment?.waypoints ?? {};
@@ -89,6 +92,7 @@ function ConfirmedRoute({mapboxAccessToken, transaction}: ConfirmedRouteProps) {
8992

9093
return !isOffline && Boolean(mapboxAccessToken?.token) ? (
9194
<DistanceMapView
95+
interactive={interactive}
9296
accessToken={mapboxAccessToken?.token ?? ''}
9397
mapPadding={CONST.MAP_PADDING}
9498
pitchEnabled={false}

src/components/MapView/MapView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {ComponentProps, MapViewOnyxProps} from './types';
2020
import utils from './utils';
2121

2222
const MapView = forwardRef<MapViewHandle, ComponentProps>(
23-
({accessToken, style, mapPadding, userLocation: cachedUserLocation, styleURL, pitchEnabled, initialState, waypoints, directionCoordinates, onMapReady}, ref) => {
23+
({accessToken, style, mapPadding, userLocation: cachedUserLocation, styleURL, pitchEnabled, initialState, waypoints, directionCoordinates, onMapReady, interactive = true}, ref) => {
2424
const navigation = useNavigation();
2525
const {isOffline} = useNetwork();
2626
const {translate} = useLocalize();
@@ -145,7 +145,7 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
145145
};
146146

147147
return !isOffline && Boolean(accessToken) && Boolean(currentPosition) ? (
148-
<View style={style}>
148+
<View style={[style, !interactive ? styles.pointerEventsNone : {}]}>
149149
<Mapbox.MapView
150150
style={{flex: 1}}
151151
styleURL={styleURL}

src/components/MapView/MapView.website.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
3838
userLocation: cachedUserLocation,
3939
directionCoordinates,
4040
initialState = {location: CONST.MAPBOX.DEFAULT_COORDINATE, zoom: CONST.MAPBOX.DEFAULT_ZOOM},
41+
interactive = true,
4142
},
4243
ref,
4344
) => {
@@ -195,6 +196,7 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
195196
}}
196197
style={StyleUtils.getTextColorStyle(theme.mapAttributionText)}
197198
mapStyle={styleURL}
199+
interactive={interactive}
198200
>
199201
{waypoints?.map(({coordinate, markerComponent, id}) => {
200202
const MarkerComponent = markerComponent;

src/components/MapView/MapViewTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type MapViewProps = {
2020
directionCoordinates?: Array<[number, number]>;
2121
// Callback to call when the map is idle / ready.
2222
onMapReady?: () => void;
23+
// Whether the map is interactable or not
24+
interactive?: boolean;
2325
};
2426

2527
type DirectionProps = {

src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ function MoneyRequestPreviewContent({
234234
>
235235
{showMapAsImage && (
236236
<View style={styles.reportActionItemImages}>
237-
<ConfirmedRoute transaction={transaction} />
237+
<ConfirmedRoute
238+
transaction={transaction}
239+
interactive={false}
240+
/>
238241
</View>
239242
)}
240243
{!showMapAsImage && hasReceipt && (

src/components/ReportActionItem/MoneyRequestView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,10 @@ function MoneyRequestView({
358358
>
359359
<View style={styles.moneyRequestViewImage}>
360360
{showMapAsImage ? (
361-
<ConfirmedRoute transaction={transaction} />
361+
<ConfirmedRoute
362+
transaction={transaction}
363+
interactive={false}
364+
/>
362365
) : (
363366
<ReportActionItemImage
364367
thumbnail={receiptURIs?.thumbnail}

0 commit comments

Comments
 (0)