Skip to content

Commit

Permalink
Merge pull request #777 from ibi-group/fix-popup-focustraps
Browse files Browse the repository at this point in the history
Fix Map Popups (and focus traps)
  • Loading branch information
amy-corson-ibigroup authored Sep 18, 2024
2 parents dc9c14e + 45820a9 commit 5c9f316
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
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

0 comments on commit 5c9f316

Please sign in to comment.