-
-
Notifications
You must be signed in to change notification settings - Fork 93
Description
Describe the bug
In select mode (and possibly other modes too) the radius suggested by the cursor changing when nearing a midpoint or vertex does not reflect what it actually is for the on click behaviour. In fact, it seems to be ~2 times as much.
Terra Draw npm version
1.15.0
To Reproduce
Steps to reproduce the behavior:
- Go to the 'Select with Mid Points' story on storybook
- Create a polygon
- Switch to select mode
- Starting far from the polygon slowly approach a midpoint until the cursor switches to a crosshair and stop
- Click with the left mouse button
- Observe how the polygon was deselected instead of a new midpoint being created
Expected behavior
It is expected that the activation area hinted by the cursor changing reflects the actual onClick behaviour.
Screenshots
Notice here how it deselects after I click as soon as the cursor turns to a crosshair, instead of creating a midpoint. Unfortunately the video does not show when the click happen but it should be easy to tell because the feature gets deselected, until the last click that is within the actual range and a midpoint is created instead.
Screen.Recording.2025-09-25.at.10.32.47.mov
Desktop (please complete the following information):
- OS: macOS 15.6.1
- Browser: chrome
- Version 140.0.7339.133
Additional context
I have investigated the cause, and I believe it has something to do with how here the midpoint/vertex distance threshold is calculated as the radius around the point, whereas onLeft click the features are retrieved (here) using the a bounding box around the cursor location.
I have tested in a fork that by changing the onMouseMove distance threshold to half of the pointerDistance it's closer to the actual threshold, but still not 100% accurate.
I'm more than happy to open a PR to address the issue if some guidance is provided. I would imagine that using the FeatureAtPointerEventBehavior during the onMouseMove event to find the midpoints would address the inconsistencies, but I am concerned about the performance implications of doing that.