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 2 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/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 = () => null, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function MapPopup({ closePopup = () => null, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element {
export function MapPopup({ closePopup = () => void, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element {

Should this be void instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a type it's a default!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but look at the type! It returns void

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a noOp function you can import

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