Skip to content

Commit 8da9211

Browse files
committed
RU-T46 PR#198 fixes
1 parent 8864c15 commit 8da9211

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/components/maps/full-screen-location-picker.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ const FullScreenLocationPicker: React.FC<FullScreenLocationPickerProps> = ({ ini
9494
return;
9595
}
9696

97-
// Create a timeout promise
97+
// Create a timeout promise with cleanup
98+
let timeoutId: ReturnType<typeof setTimeout> | undefined;
9899
const timeoutPromise = new Promise<never>((_, reject) => {
99-
setTimeout(() => reject(new Error('Location timeout')), LOCATION_TIMEOUT);
100+
timeoutId = setTimeout(() => reject(new Error('Location timeout')), LOCATION_TIMEOUT);
100101
});
101102

102103
// Race between getting location and timeout
@@ -107,6 +108,9 @@ const FullScreenLocationPicker: React.FC<FullScreenLocationPickerProps> = ({ ini
107108
timeoutPromise,
108109
]);
109110

111+
// Clear timeout if location resolved first
112+
if (timeoutId !== undefined) clearTimeout(timeoutId);
113+
110114
if (!isMountedRef.current) return;
111115

112116
const newLocation = {

0 commit comments

Comments
 (0)