Open patryk-smc opened 3 months ago
This appears to be a bug in the Extension code.
<Map
zoom={15}
...
/>
should be
<Map
zoom={currentZoom}
...
/>
Hey @ryan-ludwig, We tried that approach, but using a controlled zoom value actually causes an even bigger issue. In this video, you can see that when I zoom using the touchpad, it keeps reverting to the initially set coordinates.
https://github.com/user-attachments/assets/c3c4d9ca-d23b-453c-874d-27067170cefc
Code:
import { MapLocation, Modal, Button, Map } from "@shopify/ui-extensions-react/checkout"
import React from "react"
export function MapModal() {
const [mapLocation, setMapLocation] = React.useState<MapLocation>({
latitude: 40.74043971054843,
longitude: -73.98826780257427,
})
const [currentZoom, setCurrentZoom] = React.useState<number>(15)
return (
<Modal id="test-modal">
<Map
apiKey="redacted"
latitude={mapLocation.latitude}
longitude={mapLocation.longitude}
zoom={currentZoom}
accessibilityLabel="Map"
onZoomChange={(zoom) => {
console.log("zoomChange", zoom)
setCurrentZoom(zoom)
}}
/>
<Button
onPress={() =>
setMapLocation({
latitude: mapLocation.latitude,
longitude: mapLocation.longitude - 0.001,
})
}
>
Go left
</Button>
<Button
onPress={() =>
setMapLocation({
latitude: mapLocation.latitude,
longitude: mapLocation.longitude + 0.001,
})
}
>
Go right
</Button>
Zoom:{currentZoom}
</Modal>
)
}
Thanks for the video and code samples @patryk-smc! We've identified the problem now and are investigating how to fix.
Thanks for the video and code samples @patryk-smc! We've identified the problem now and are investigating how to fix.
Awesome. Thank you. If there is anything I could do to help - let me know 😊
Hi @ryan-ludwig just wondered if there any updates you can share? Thank you!
Hey @patryk-smc no updates yet. The issue is triaged and we'll get to it when we can
Hey @patryk-smc no updates yet. The issue is triaged and we'll get to it when we can
Thanks for update Jun!
Please list the package(s) involved in the issue, and include the version you are using
Describe the bug
When the
latitude
andlongitude
props are updated to change the map location, and a zoom prop is set, the map incorrectly resets itszoom
level to the value specified in thezoom
prop instead of preserving the current zoom level.Steps to reproduce the behavior:
Expected behavior
The map should preserve the value of the current zoom level when updating location
Screenshots
https://github.com/user-attachments/assets/f0cbfb8f-e4d2-4ad1-8a54-8407290bba2c
Additional context