From e938eef74040f375fbbb6f7a5cab827a960b20e8 Mon Sep 17 00:00:00 2001 From: alexsparkes Date: Sat, 7 Feb 2026 22:28:56 +0000 Subject: [PATCH] fix: Refactor event handling in LocationSearch and streamline modal navigation logic in Modals --- .../Form/Settings/LocationSearch/LocationSearch.jsx | 4 +++- src/features/misc/modals/Modals.jsx | 10 ++++------ src/features/weather/Weather.jsx | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/Form/Settings/LocationSearch/LocationSearch.jsx b/src/components/Form/Settings/LocationSearch/LocationSearch.jsx index 8b83ca00..94bee5cb 100644 --- a/src/components/Form/Settings/LocationSearch/LocationSearch.jsx +++ b/src/components/Form/Settings/LocationSearch/LocationSearch.jsx @@ -60,7 +60,9 @@ const LocationSearch = memo((props) => { // Also ignore clicks on color input labels and wrappers const target = event.target; if (target.tagName === 'LABEL' && target.htmlFor) { - const associatedInput = document.getElementById(target.htmlFor) || document.querySelector(`input[name="${target.htmlFor}"]`); + const associatedInput = + document.getElementById(target.htmlFor) || + document.querySelector(`input[name="${target.htmlFor}"]`); if (associatedInput && associatedInput.type === 'color') { return; } diff --git a/src/features/misc/modals/Modals.jsx b/src/features/misc/modals/Modals.jsx index d7a57868..8d7acf95 100644 --- a/src/features/misc/modals/Modals.jsx +++ b/src/features/misc/modals/Modals.jsx @@ -176,13 +176,11 @@ const Modals = () => { } else if (action === false && type === 'mainModal') { // Mark modal as closing to prevent sync logic from interfering setIsModalClosing(true); - // Wait for close animation and cleanup to complete, then navigate + // Navigate immediately to avoid URL flash + navigate('/'); + // Wait for close animation to complete, then reset closing flag setTimeout(() => { - navigate('/'); - // Reset the closing flag after navigation - setTimeout(() => { - setIsModalClosing(false); - }, 100); + setIsModalClosing(false); }, 350); } }; diff --git a/src/features/weather/Weather.jsx b/src/features/weather/Weather.jsx index f30d052a..a1295aa5 100644 --- a/src/features/weather/Weather.jsx +++ b/src/features/weather/Weather.jsx @@ -45,7 +45,7 @@ const WeatherWidget = memo(() => { const updateWeather = useCallback(async () => { const currentLocation = getLocationFromStorage(); setLocation(currentLocation); - + const data = await getWeather(currentLocation); console.log('Weather data received:', data); if (data) {