Select to view content in your preferred language

map-components-react stopPropagation() funtion does not work when used react in components

206
2
Jump to solution
08-29-2024 09:07 AM
RandallDodson
New Contributor

Hello I am trying to rectify the component but some view items are not having the expected effect.

<ArcgisMap
itemId="e691172598f04ea8881cd2a4adaa45ba"

onArcgisViewDrag={ (event:ViewDragEvent) =>
{
// prevents panning with the mouse drag event
event.stopPropagation();

}
}

onArcgisViewKeyDown={(event: ViewKeyDownEvent) => {
// prevents panning with the arrow keys
const keyPressed = event.key;
if (keyPressed?.length<0 && keyPressed.slice(0, 5) === "Arrow") {
event.stopPropagation();
}

}}
>
</ArcgisMap>

both the `onArcgisViewDrag` event & the `onArcgisViewKeyDown` trigger but the `stopPropagation()` does not prevent movement

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

The components emit CustomEvents that wrap the native view mouse events, like CustomEvent<ViewDragEvent>.

Try to `event.detail.stopPropagation()`.

View solution in original post

0 Kudos
2 Replies
RandallDodson
New Contributor

Versions used in package.json

"@arcgis/core": "^4.30.9",
"@arcgis/map-components-react": "^4.30.7",
0 Kudos
ReneRubalcava
Honored Contributor

The components emit CustomEvents that wrap the native view mouse events, like CustomEvent<ViewDragEvent>.

Try to `event.detail.stopPropagation()`.

0 Kudos