Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlay Popup Behavior Correction #1288

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions lib/components/map/itinerary-summary-overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { connect } from 'react-redux'

Check failure on line 1 in lib/components/map/itinerary-summary-overlay.tsx

View workflow job for this annotation

GitHub Actions / test-build-release

Parameter 'mp' implicitly has an 'any' type.
import { Feature, lineString, LineString, Position } from '@turf/helpers'
import { Itinerary, Location } from '@opentripplanner/types'
import { Marker } from 'react-map-gl'
Expand Down Expand Up @@ -152,14 +152,18 @@
)

if (!itins || !visible) return <></>
const mergedItins: ItinWithGeometry[] = addTrueIndex(
doMergeItineraries(itins).mergedItineraries.map(addItinLineString)
const indexedItins: ItinWithGeometry[] = addTrueIndex(
itins.map(addItinLineString)
)
const mergedItins = doMergeItineraries(indexedItins).mergedItineraries

const midPoints = mergedItins.reduce(
miles-grant-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
(prev: ItinUniquePoint[], curItin: ItinWithGeometry) => {
prev.push(getUniquePoint(curItin, prev))
return prev
},
[]
)

const midPoints = mergedItins.reduce<ItinUniquePoint[]>((prev, curItin) => {
prev.push(getUniquePoint(curItin, prev))
return prev
}, [])
// The first point is probably not well placed, so let's run the algorithm again
if (midPoints.length > 1) {
midPoints[0] = getUniquePoint(mergedItins[0], midPoints)
Expand All @@ -186,18 +190,8 @@
onClick={() => {
setActive({ index: mp.itin.index })
}}
// TODO: useCallback here (getting weird errors?)
onMouseEnter={() => {
setSharedTimeout(
setTimeout(() => {
setVisible({ index: mp.itin.index })
}, 150)
)
}}
onMouseLeave={() => {
sharedTimeout && clearTimeout(sharedTimeout)
setVisible({ index: null })
}}
// TODO: restore setting visible itinerary on hover without
// causing endless re-render?
>
<MetroItineraryRoutes
expanded={false}
Expand Down
Loading