diff --git a/lib/gtfs/components/gtfs-search.js b/lib/gtfs/components/gtfs-search.js index 6a8e26faa..ad73fa6a8 100644 --- a/lib/gtfs/components/gtfs-search.js +++ b/lib/gtfs/components/gtfs-search.js @@ -153,11 +153,17 @@ class GtfsSearch extends Component { stops && stopOptions.push(...stops.map(s => _entityToOption(s, feed))) routes && routeOptions.push( ...routes - // Remove specified entity ids (route ids in this case) to exclude, except the current value. - .filter(route => - !excludedEntityIds.includes(route.route_id) || - // (Extended type checks are for flow validation.) - (route.route_id === (typeof currentOption === 'object' ? currentOption && currentOption.value : currentOption)) + // Keep routes whose ids are not excluded and that are not the one selected in the dropdown. + .filter(route => { + const { route_id: routeId } = route + if (routeId === null || routeId === undefined) return false + + const isExcluded = excludedEntityIds && excludedEntityIds.includes(routeId) + const isSameAsCurrent = + // (Extended type checks are for flow validation.) + routeId === (typeof currentOption === 'object' ? currentOption && currentOption.value : currentOption) + return !isExcluded && !isSameAsCurrent + } ) .map(r => _entityToOption(r, feed)) )