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

Fix Map Popups (and focus traps) #777

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions packages/map-popup/src/__snapshots__/MapPopup.story.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ exports[`Map Popup FloatingCarEntity smoke-test 1`] = `

exports[`Map Popup FloatingVehicleEntity smoke-test 1`] = `
<div class="styled__MapOverlayPopup-sc-12kjso7-1 idXkMr">
<div id="focus-bike_6861-popup-focus-trap"
<div id="focus-22bike_686122-popup-focus-trap"
role="presentation"
>
<header class="styled__PopupTitle-sc-12kjso7-3 cjkEhb">
Expand Down Expand Up @@ -116,7 +116,7 @@ exports[`Map Popup FloatingVehicleEntity smoke-test 1`] = `

exports[`Map Popup StationEntity smoke-test 1`] = `
<div class="styled__MapOverlayPopup-sc-12kjso7-1 idXkMr">
<div id="focus-hub_1580-popup-focus-trap"
<div id="focus-22hub_158022-popup-focus-trap"
role="presentation"
>
<header class="styled__PopupTitle-sc-12kjso7-3 cjkEhb">
Expand Down
4 changes: 2 additions & 2 deletions packages/map-popup/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function entityIsStation(entity: Entity): entity is Station {
/**
* Renders a map popup for a stop, scooter, or shared bike
*/
export function MapPopup({ closePopup = null, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element {
export function MapPopup({ closePopup = () => {}, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element {
const intl = useIntl()
if (!entity) return <></>

Expand All @@ -115,7 +115,7 @@ export function MapPopup({ closePopup = null, configCompanies, entity, getEntity
const stopId = !bikesAvailablePresent && entity?.code || entity.id.split(":")[1] || entity.id

// Double quotes make the query invalid, so remove them from the id just in case
const id = `focus-${entity.id}-popup`.replace(/"/g, "")
const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, "")}-popup`

return (
<Styled.MapOverlayPopup>
Expand Down
1 change: 1 addition & 0 deletions packages/otp2-tile-overlay/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const OTP2TileLayerWithPopup = ({
onClose={() => setClickedEntity(null)}
>
<EntityPopup
closePopup={() => setClickedEntity(null)}
configCompanies={configCompanies}
entity={{ ...clickedEntity, id: clickedEntity?.id || clickedEntity?.gtfsId }}
setLocation={setLocation ? (location) => { setClickedEntity(null); setLocation(location) } : null}
Expand Down
Loading