Skip to content

Commit

Permalink
PB-960: handle long press events error on some mobiles
Browse files Browse the repository at this point in the history
Issue : on some phones, a long press event would also fire a single press event afterwards, causing the application to open both a location popup and an infobox.
Cause : setting the longClickTriggered boolean was not registered while in the longClickTimeout function, most likely due to a scoping issue.

Fix : we set the longClickTriggered boolean in the 'onMapRightClick' event instead. We also added a small parameter in the function to tell if we need to set up the flag or not, as desktop users won't need this.

PB-960: add updateLongClickTriggered to event

- We add the updateLongClickTriggered to the 'event' item in onMapRightClick
  • Loading branch information
ltkum committed Sep 26, 2024
1 parent d0f0931 commit 72ad49e
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export default function useMapInteractions(map) {

function onMapRightClick(event) {
clearTimeout(longClickTimeout)
longClickTriggered = event.updateLongClickTriggered ?? false
store.dispatch('click', {
clickInfo: new ClickInfo({
coordinate: event.coordinate,
Expand Down Expand Up @@ -212,14 +213,14 @@ export default function useMapInteractions(map) {
// LocationPopup by touching the same-ish spot for 500ms
longClickTimeout = setTimeout(() => {
if (!mapHasMoved) {
longClickTriggered = true
// we are outside of OL event handling, on the HTML element, so we do not receive map pixel and coordinate automatically
const pixel = map.getEventPixel(event)
const coordinate = map.getCoordinateFromPixel(pixel)
onMapRightClick({
...event,
pixel,
coordinate,
updateLongClickTriggered: true,
})
}
mapHasMoved = false
Expand Down

0 comments on commit 72ad49e

Please sign in to comment.