fix a corner case where pointer interaction generates two points #1780
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Because we're checking for strict inequality of the distance to the best facet, it can happen that we display 2 tips if the pointer is exactly at the same distance from two target points in different facets. This fixes this corner case, by retaining only the first point in case of strict equality.
I've seen it happen once, by chance, when I was playing with https://observablehq.com/d/a03f70ae5c5962c4 — so I'm sure it can happen in the wild, but it's difficult to reproduce: you need an environment where the pointer has integer coordinates (this depends on the browser, I think?), and the two targets have integer coordinates (e.g., using the round: true option on x — it's on by default on fx).