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

Prevent double clicks for point annotations #896

Merged
merged 6 commits into from
Aug 21, 2024
Merged

Conversation

dlangenk
Copy link
Member

fixes #491

@dlangenk dlangenk requested a review from mzur July 26, 2024 07:28
Copy link
Member

@mzur mzur left a comment

Choose a reason for hiding this comment

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

I can produce incorrect features with this change (the blue ones):

Screencast.from.26.07.2024.09.58.05.webm

If I try to delete one of those, the app crashes. The features that are created within the cool down period should be immediately removed again. Also maybe we could check if the new point is "near" the previous point (there should be an OpenLayers method for that)? If not, users should be able to create points faster than the cool down period (as in the video).

@dlangenk
Copy link
Member Author

If i throttle my connection speed I also see that problem. Before I simply could not reproduce that.

@mzur
Copy link
Member

mzur commented Jul 26, 2024

Strange, it should not have anything to do with the connection speed. This is purely client-side. You have to click faster than the 400 ms for this to happen.

@dlangenk
Copy link
Member Author

I guess now the point is removed after all, BUT the map is also dragged after a double click. I also added the distance to last annotation feature.

Copy link
Member

@mzur mzur left a comment

Choose a reason for hiding this comment

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

I've updated the code a bit so the point and time are only updated if drawing points. However, this still fails because there is no distanceTo() method in an OpenLayers geometry. LLM fail? 😄

This is likely also the reason why the map is "dragged" for you because there should be a JS error in your console.

@dlangenk
Copy link
Member Author

Pretty sure that I actually got a distance and no error, but I'll have a look at this. No LLM fail😉, but rather StackOverflow

@dlangenk
Copy link
Member Author

Don't know why the console error slipped. Now it works, without any errors ;-) Please have a look if the position of the computeDistance function is correct or if it should be somewhere else.

@dlangenk dlangenk requested a review from mzur August 20, 2024 11:18
Copy link
Member

@mzur mzur left a comment

Choose a reason for hiding this comment

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

The distance calculation works but the feature wasn't removed for me now, too. This was because the feature is added to the source after the drawend event was handled. I fixed that now.

@mzur mzur changed the title prevent double clicks for point annotations Prevent double clicks for point annotations Aug 21, 2024
@mzur mzur merged commit a8117e4 into master Aug 21, 2024
6 checks passed
@mzur mzur deleted the preventDoubleClick branch August 21, 2024 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Catch double-click for point annotations in UI
2 participants