Skip to content

Commit 221cd61

Browse files
committed
Fix stop visibility issue in route view on map
Now the stops that are on the route will not be visible if the route is not visible. Previously the stops would be visible on map even when user filtered out the route and stops.
1 parent d59d183 commit 221cd61

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

ui/src/components/map/Map.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export const MapComponent: ForwardRefRenderFunction<
221221
stops={stops}
222222
terminals={terminals}
223223
displayedRouteIds={displayedRouteIds}
224+
showRoute={showRoute}
224225
ref={editorRefs.stopsRef}
225226
/>
226227
<StopAreas areas={areas} ref={editorRefs.stopAreasRef} />

ui/src/components/map/stops/Stops.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,13 @@ function useFilteredStops(
8484
type StopsProps = {
8585
readonly areas: ReadonlyArray<MapStopArea>;
8686
readonly displayedRouteIds: ReadonlyArray<string>;
87+
readonly showRoute: boolean;
8788
readonly stops: ReadonlyArray<MapStop>;
8889
readonly terminals: ReadonlyArray<MapTerminal>;
8990
};
9091

9192
export const StopsImpl: ForwardRefRenderFunction<StopsRef, StopsProps> = (
92-
{ areas, displayedRouteIds, stops, terminals },
93+
{ areas, displayedRouteIds, showRoute, stops, terminals },
9394
ref,
9495
) => {
9596
const [mapViewState, setMapViewState] = useMapViewState();
@@ -117,8 +118,10 @@ export const StopsImpl: ForwardRefRenderFunction<StopsRef, StopsProps> = (
117118

118119
const { getStopVehicleMode, getStopHighlighted, getStopShouldBeGray } =
119120
useMapStops(displayedRouteIds);
120-
const filterStopsByVehicleMode =
121-
useFilterStopsByVehicleMode(getStopVehicleMode);
121+
const filterStopsByVehicleMode = useFilterStopsByVehicleMode(
122+
getStopVehicleMode,
123+
showRoute,
124+
);
122125

123126
const { setLoadingState: setFetchStopsLoadingState } = useLoader(
124127
Operation.FetchStops,

ui/src/components/map/stops/hooks/useFilterStopsByVehicleMode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function useFilterStopsByVehicleMode(
1010
getStopVehicleMode: (
1111
stop: MapStop,
1212
) => ReusableComponentsVehicleModeEnum | undefined,
13+
showRoute: boolean,
1314
) {
1415
const { stopFilters } = useAppSelector(selectMapFilter);
1516
const { visibleRouteStopLabels } = useVisibleRouteStops();
@@ -18,9 +19,8 @@ export function useFilterStopsByVehicleMode(
1819
(stops: ReadonlyArray<MapStop>): ReadonlyArray<MapStop> =>
1920
stops.filter((stop) => {
2021
const vehicleMode = parseVehicleMode(getStopVehicleMode(stop));
21-
const isStopInVisibleRoutes = visibleRouteStopLabels.includes(
22-
stop.label,
23-
);
22+
const isStopInVisibleRoutes =
23+
showRoute && visibleRouteStopLabels.includes(stop.label);
2424

2525
if (vehicleMode === ReusableComponentsVehicleModeEnum.Bus) {
2626
return (
@@ -40,6 +40,6 @@ export function useFilterStopsByVehicleMode(
4040
isStopInVisibleRoutes
4141
);
4242
}),
43-
[getStopVehicleMode, stopFilters, visibleRouteStopLabels],
43+
[getStopVehicleMode, showRoute, stopFilters, visibleRouteStopLabels],
4444
);
4545
}

0 commit comments

Comments
 (0)