From 5e993a1f2e69e70ee502b79edfe48ae6a18b9066 Mon Sep 17 00:00:00 2001 From: Jordan Streiff Date: Fri, 24 Jul 2026 18:33:19 -0400 Subject: [PATCH] Fix add similar issue for iOS Co-authored-by: Cursor --- src/components/connect/ConnectLocation.js | 6 +++--- src/components/connect/ConnectNewLocation.js | 8 +++++++- src/redux/locationSlice.js | 10 +++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/components/connect/ConnectLocation.js b/src/components/connect/ConnectLocation.js index 4be6c3239..3ccea8720 100644 --- a/src/components/connect/ConnectLocation.js +++ b/src/components/connect/ConnectLocation.js @@ -27,7 +27,7 @@ const LessPaddingButton = styled(Button)` padding: 0 10px; ` -const ToastContent = () => { +const ToastContent = ({ location }) => { const { t } = useTranslation() const history = useAppHistory() const dispatch = useDispatch() @@ -57,7 +57,7 @@ const ToastContent = () => { { - dispatch(duplicateIntoNewLocation()) + dispatch(duplicateIntoNewLocation(location)) history.push(`/locations/init`) }} > @@ -225,7 +225,7 @@ const ConnectLocation = ({ } } else if (isSuccessfullyAdded) { toastIdRef.current = toast.success( - , + , { autoClose: false, style: { width: '100%' }, diff --git a/src/components/connect/ConnectNewLocation.js b/src/components/connect/ConnectNewLocation.js index 0f8ffdf0d..59c25db58 100644 --- a/src/components/connect/ConnectNewLocation.js +++ b/src/components/connect/ConnectNewLocation.js @@ -36,7 +36,13 @@ const ConnectNewLocation = () => { // Should only happen for an artificially constructed URL history.push('/map') } - }, [dispatch, locationId, hasInitialView, isDesktop]) //eslint-disable-line + /* + * Mount-only: after a successful submit, locationId changes from 'new' to + * the new location's id while this component is still mounted. Re-running + * would call initNewLocation and wipe the just-added location from Redux, + * which the success page and 'Add similar' still need. + */ + }, []) //eslint-disable-line return null } diff --git a/src/redux/locationSlice.js b/src/redux/locationSlice.js index 6af33736d..258d6daba 100644 --- a/src/redux/locationSlice.js +++ b/src/redux/locationSlice.js @@ -92,7 +92,15 @@ const locationSlice = createSlice({ clearLocation: (state) => { Object.assign(state, initialState) }, - duplicateIntoNewLocation: (state) => { + duplicateIntoNewLocation: (state, action) => { + /* + * The location captured when the success toast was created. Restore it + * in case something (e.g. the mobile drawer closing through /map) + * cleared the slice before the user tapped 'Add similar'. + */ + if (action.payload) { + state.location = action.payload + } state.isLoading = false state.isBeingEdited = false state.locationId = 'new'