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: Android - Distance - Waypoint does not change position correctly by dragging. #41378

Merged
merged 12 commits into from
May 28, 2024
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ function IOURequestStepDistance({
<View style={styles.flex1}>
<DraggableList
data={waypointsList}
keyExtractor={(item) => item}
keyExtractor={(item) => (waypoints[item]?.keyForList ?? waypoints[item]?.address ?? '') + item}
shouldUsePortal
onDragEnd={updateWaypoints}
ref={scrollViewRef}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/iou/request/step/IOURequestStepWaypoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function IOURequestStepWaypoint({
name: values.name ?? '',
lat: values.lat ?? 0,
lng: values.lng ?? 0,
keyForList: `${(values.name ?? 'waypoint') as string}_${Date.now()}`,
};
saveWaypoint(waypoint);
}
Expand All @@ -139,6 +140,7 @@ function IOURequestStepWaypoint({
lng: values.lng ?? 0,
address: values.address ?? '',
name: values.name ?? '',
keyForList: `${values.name ?? 'waypoint'}_${Date.now()}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry i just notice this inconsistency, can you help me understand why here we use name and above it we use waypointValue (which is address) ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

different by mistake, updated now to values.name.

};

Transaction.saveWaypoint(transactionID, pageIndex, waypoint, action === CONST.IOU.ACTION.CREATE);
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/RecentWaypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ type RecentWaypoint = {

/** The longitude of the waypoint */
lng?: number;

/** A unique key for waypoint is required for correct draggable list rendering */
keyForList?: string;
};

export default RecentWaypoint;
3 changes: 3 additions & 0 deletions src/types/onyx/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type Waypoint = {

/** Address street line 2 */
street2?: string;

/** A unique key for waypoint is required for correct draggable list rendering */
keyForList?: string;
};

type WaypointCollection = Record<string, RecentWaypoint | Waypoint>;
Expand Down
Loading