Select to view content in your preferred language

4.28 Sketch Tool - View click events not working in draw mode

2450
5
Jump to solution
11-08-2023 10:47 PM
FC_Basson
MVP Regular Contributor

In 4.27, the view could listen and respond to click events (e.g. right click) while in drawing mode (activeTool not null or reshape/transform).  Now with 4.28, when you are in drawing mode, the view event listener for click events is not firing at all.  Only once the Sketch tool activeTool returns to null or reshape/transform, the view click events are working.  How can I set up the view to listen for click events while the activeTool is in draw mode?

0 Kudos
1 Solution

Accepted Solutions
JoseBanuelos
Esri Contributor

@FC_Basson ,
Appreciate you reaching out to relay this difference in behavior from the last release. Would you mind providing a codepen with a simplified example of your use case? Code snippet would work as well, we just want to make sure we account for your use case while we investigate this. We had an initial recommendation of relying on the view "immediate-click" event instead of the "click" event whenever you are actively drawing, whether it was 4.27 or 4.28. However, we want to make sure we understand your workflow to guarantee our recommendation works in your case as well. 

Thanks!
Jose

View solution in original post

5 Replies
JoseBanuelos
Esri Contributor

@FC_Basson ,
Appreciate you reaching out to relay this difference in behavior from the last release. Would you mind providing a codepen with a simplified example of your use case? Code snippet would work as well, we just want to make sure we account for your use case while we investigate this. We had an initial recommendation of relying on the view "immediate-click" event instead of the "click" event whenever you are actively drawing, whether it was 4.27 or 4.28. However, we want to make sure we understand your workflow to guarantee our recommendation works in your case as well. 

Thanks!
Jose

FC_Basson
MVP Regular Contributor

Hi Jose

Here is a codepen for 4.27: https://codepen.io/fcbasson/pen/abXWLOz .  Once you activate a drawing tool, the view "click" event still fires.  If you change the version to 4.28, the behaviour changes.

I also had a look at the "immediate-click" event and it might be the solution to my issue.  I'll do some further testing and get back to you.

 

PS:  I did some testing with the "immediate-click" event and that seems to solve my issue.

0 Kudos
JoseBanuelos
Esri Contributor

@FC_Basson ,

I am glad this works for your use case. I took a look at the codepen, and the "immediate-click" will work well in this situation. We did find that this is indeed a bug, and we have logged an issue internally. We will look to provide a fix for 4.29 for the single click event listener issue. In the meantime you can continue to use the recommended "immediate-click" event listener until we provide the fix or you can continue to use this recommended workflow indefinitely.

Thanks!

Jose

JoelBennett
MVP Regular Contributor

The workflow described in the third paragraph of this post stopped working again in 4.28, although this time instead of a feature being created, nothing happens.  It appears to the be same underlying issue described in this thread, which I didn't come to until troubleshooting the issue on my own.  If it helps any, below is what I found.

It appears the culprit is in the "handleInputEvent" function of the esri/views/interactive/ToolViewManagerManipulatorState module.  In particular, the last line of the case for "immediate-click" is:

l?.consumesClicks && a.stopPropagation();

 

Maybe it should be something like:

l?.consumesClicks && a.button !== 2 && a.stopPropagation();
0 Kudos
JoseBanuelos
Esri Contributor

@FC_Basson 

This regression has now been resolved in the upcoming release of 4.29! Again we appreciate you reaching out to inform us of this. You can continue to rely on the immediate-click, just know the issue has been resolved.

Thanks,

Jose Banuelos