Skip to content

Commit 8bca9f2

Browse files
author
Andrii Ovcharenko
committed
copilot suggestion fix
1 parent 994e16c commit 8bca9f2

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/model/internal-hit-test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import type { HoveredItemType } from './chart-model';
22

33
/**
4-
* Internal hit-test priority used to break ties between overlapping candidates.
4+
* Internal hit-test priority used for hover arbitration.
5+
*
6+
* Point hits receive a special override over non-point hits. Otherwise distance
7+
* decides, and equal-distance non-point ties preserve the existing visual/source
8+
* order instead of preferring a higher numeric priority.
59
*/
610
export enum HitTestPriority {
711
/**
@@ -120,6 +124,7 @@ export function isBetterHit(candidate: InternalHitTestCandidate, currentBest: In
120124
return candidate.distance < currentBest.distance;
121125
}
122126

123-
// return candidate.priority > currentBest.priority;
127+
// Preserve the existing draw/source order for equal-distance non-point ties.
128+
// This prevents hidden strokes from overtaking visually covering range hits.
124129
return false;
125130
}

src/model/ipane-primitive.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export interface PrimitiveHoveredItem {
9595
* - `0` for range-style hits such as covered regions
9696
* - `1` for line-style hits such as strokes
9797
* - `2` for point-style hits such as explicit markers
98+
*
99+
* Point-style hits receive special precedence over non-point hits. Otherwise
100+
* distance decides, and equal-distance non-point ties preserve the existing
101+
* visual/source order.
98102
*/
99103
hitTestPriority?: number;
100104
/**

src/model/pane-hit-test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ function itemTypeFromCandidate(source: IPrimitiveHitTestSource, candidate: Inter
3434
}
3535

3636
if (source instanceof Series) {
37-
if (source.seriesType() === 'Custom') {
38-
return 'custom';
39-
}
40-
// Built-in series pane-view hit tests never set externalId;
41-
// only price-line renderer hits (horizontal-line-renderer) do.
37+
// Pane-view series hits never tag themselves as price lines; the
38+
// horizontal-line renderer path does so via `externalId`, including
39+
// custom-series price lines.
4240
if (candidate.externalId !== undefined) {
4341
return 'price-line';
4442
}
43+
if (source.seriesType() === 'Custom') {
44+
return 'custom';
45+
}
4546
switch (candidate.priority) {
4647
case HitTestPriority.Point:
4748
return 'series-point';

0 commit comments

Comments
 (0)