From fda50c598e164647715190bae012369e55932990 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Thu, 18 Apr 2024 13:09:42 -0400 Subject: [PATCH 1/2] avoid non-itin-view jumping --- lib/components/app/responsive-webapp.js | 4 +++- lib/components/map/route-preview-overlay.tsx | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/components/app/responsive-webapp.js b/lib/components/app/responsive-webapp.js index 74fea9add..668434186 100644 --- a/lib/components/app/responsive-webapp.js +++ b/lib/components/app/responsive-webapp.js @@ -62,6 +62,7 @@ class ResponsiveWebapp extends Component { formChanged, intl, location, + mainPanelContent, map, matchContentToUrl, query, @@ -98,7 +99,7 @@ class ResponsiveWebapp extends Component { setLocationToCurrent({ locationType: 'from' }, intl) setMapCenter(map, pt) } - } else if (query.from && query.to) { + } else if (query.from && query.to && mainPanelContent === null) { map?.fitBounds([query.from, query.to], { duration: 500, padding: getFitBoundsPadding(map, 0.2) @@ -259,6 +260,7 @@ const mapStateToProps = (state) => { activeSearchId: state.otp.activeSearchId, currentPosition: state.otp.location.currentPosition, locale: state.otp.ui.locale, + mainPanelContent: state.otp.ui.mainPanelContent, mobileScreen: state.otp.ui.mobileScreen, modeGroups: state.otp.config.modeGroups, popupContent: state.otp.ui.popup, diff --git a/lib/components/map/route-preview-overlay.tsx b/lib/components/map/route-preview-overlay.tsx index 8b02e7362..0559cf021 100644 --- a/lib/components/map/route-preview-overlay.tsx +++ b/lib/components/map/route-preview-overlay.tsx @@ -14,6 +14,7 @@ import { type Props = { from: Location geometries: string[] + mainPanelContent: number | null to: Location visible?: boolean } @@ -21,17 +22,23 @@ type Props = { * This overlay will display thin gray lines for a set of geometries. It's to be used * as a stopgap until we make full use of Transitive! */ -const RoutePreviewOverlay = ({ from, geometries, to, visible }: Props) => { +const RoutePreviewOverlay = ({ + from, + geometries, + mainPanelContent, + to, + visible +}: Props) => { // Center the map over the endpoints when this overlay is shown. const { current: map } = useMap() useEffect(() => { - if (visible) { + if (visible && mainPanelContent === null) { map?.fitBounds([from, to], { duration: 500, padding: getFitBoundsPadding(map, 0.2) }) } - }, [map, visible, from, to]) + }, [map, visible, from, to, mainPanelContent]) if (!geometries || !visible) return <> @@ -76,7 +83,7 @@ const RoutePreviewOverlay = ({ from, geometries, to, visible }: Props) => { // TODO: Typescript state const mapStateToProps = (state: any) => { - const { activeSearchId, config } = state.otp + const { activeSearchId, config, ui } = state.otp // Only show this overlay if the metro UI is explicitly enabled if (config.itinerary?.showFirstResultByDefault !== false) { return {} @@ -102,6 +109,7 @@ const mapStateToProps = (state: any) => { return { from, geometries, + mainPanelContent: ui.mainPanelContent, to, visible: // We need an explicit check for undefined and null because 0 From 6852042a79e3dc191dcbea0e22a976e205432d48 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Wed, 29 May 2024 11:21:29 -0400 Subject: [PATCH 2/2] update yarn lock --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 78e072aa4..f950b13b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2434,7 +2434,7 @@ "@opentripplanner/location-icon" "^1.4.1" flat "^5.0.2" -"@opentripplanner/geocoder@^2.0.1", "@opentripplanner/geocoder@^2.2.2": +"@opentripplanner/geocoder@^2.2.2": version "2.2.2" resolved "https://registry.yarnpkg.com/@opentripplanner/geocoder/-/geocoder-2.2.2.tgz#8ddc669287ccdfff1a5cce14d1fa8049421c6480" integrity sha512-tJIOOE5N9kpMj0ji1YyVfWwg4yAFVs7Ks+EET67acql768bXwRE6rHoX6oaHvKhbCDjaQ7kuPIwi1BYWHQgg0Q==