diff --git a/frontend/components/dashboard/CitySidebar.tsx b/frontend/components/dashboard/CitySidebar.tsx
index 2fa2de61..34ee1219 100644
--- a/frontend/components/dashboard/CitySidebar.tsx
+++ b/frontend/components/dashboard/CitySidebar.tsx
@@ -251,7 +251,7 @@ export function CitySidebar() {
className={clsx("city-item", isActive && "active")}
onClick={() =>
startTransition(() => {
- void store.selectCity(city.name);
+ void store.focusCity(city.name);
})
}
>
diff --git a/frontend/components/dashboard/MapCanvas.tsx b/frontend/components/dashboard/MapCanvas.tsx
index 569dadc2..706ec0c3 100644
--- a/frontend/components/dashboard/MapCanvas.tsx
+++ b/frontend/components/dashboard/MapCanvas.tsx
@@ -16,7 +16,7 @@ export function MapCanvas() {
onMapInteractionChange: store.setMapInteractionActive,
onRegisterStopMotion: store.registerMapStopMotion,
onSelectCity: (cityName) => {
- void store.selectCity(cityName);
+ void store.focusCity(cityName);
},
selectedCity: store.selectedCity,
selectedDetail: store.selectedDetail,
diff --git a/frontend/components/dashboard/PolyWeatherDashboard.tsx b/frontend/components/dashboard/PolyWeatherDashboard.tsx
index d27d4209..49f071db 100644
--- a/frontend/components/dashboard/PolyWeatherDashboard.tsx
+++ b/frontend/components/dashboard/PolyWeatherDashboard.tsx
@@ -280,7 +280,7 @@ function OpportunityStrip({ snapshots }: { snapshots: CitySnapshot[] }) {
key={city.name}
type="button"
className="opportunity-card"
- onClick={() => void store.selectCity(city.name)}
+ onClick={() => void store.focusCity(city.name)}
>
{city.display_name}
diff --git a/frontend/hooks/useDashboardStore.tsx b/frontend/hooks/useDashboardStore.tsx
index 706e8878..ae5531d1 100644
--- a/frontend/hooks/useDashboardStore.tsx
+++ b/frontend/hooks/useDashboardStore.tsx
@@ -41,6 +41,7 @@ interface DashboardStoreValue extends DashboardState {
force?: boolean,
depth?: "panel" | "nearby" | "full",
) => Promise;
+ focusCity: (cityName: string) => Promise;
forecastModalMode: ForecastModalMode | null;
futureModalDate: string | null;
loadCities: () => Promise;
@@ -804,6 +805,15 @@ export function DashboardStoreProvider({
});
};
+ const focusCity = async (cityName: string) => {
+ setSelectedCity(cityName);
+ setIsPanelOpen(false);
+ setSelectedForecastDate(null);
+ setFutureModalDate(null);
+ setForecastModalMode(null);
+ void ensureCitySummary(cityName).catch(() => null);
+ };
+
useEffect(() => {
if (typeof window === "undefined") return;
if (selectedCity) {
@@ -1016,6 +1026,7 @@ export function DashboardStoreProvider({
setIsPanelOpen(false);
},
ensureCityDetail,
+ focusCity,
forecastModalMode,
futureModalDate,
historyState,