Skip to content

Commit

Permalink
Merge pull request #41378 from Krishna2323/krishna2323/issue/40105
Browse files Browse the repository at this point in the history
fix: Android - Distance - Waypoint does not change position correctly by dragging.
  • Loading branch information
rlinoz authored May 28, 2024
2 parents fab9b3f + 257d956 commit 322d6fe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
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()}`,
};

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

0 comments on commit 322d6fe

Please sign in to comment.