Commit 71ccc2a
authored
fix(tldraw): bound selection edge and rotate handle hit areas (tldraw#8926)
In order to stop edge resize handles from stealing hits near the corners
(tldraw#8840), this PR bounds the edge and rotate handle hit geometry in
`SelectionForegroundOverlayUtil`. Edge handles were modeled as unfilled
`Edge2d` lines, which the `OverlayManager` inflates by the global
`hitTestMargin` (8/zoom on each side). That made the edge hit band wider
than the corner box (≈6.75/zoom half-extent), so the edge won hit tests
right at the corner. Edges are now bounded filled `Polygon2d` rectangles
matching the pre-overlay dimensions (`targetSize` per side, ≈4.5/zoom),
restoring the corner-wins-near-corners behavior. The rotate handle
radius is also set to exactly half the corner box width.
### Change type
- [x] `bugfix`
### Test plan
1. Select a shape and move the pointer just outside a corner — the
corner resize cursor should win over the edge cursor.
2. Hover the middle of an edge — the edge resize handle should still be
reachable.
3. Hover a rotate corner — its circular hit area should be half the
corner box width.
- [x] Unit tests
### Release notes
- Fix selection edge resize handles overlapping corner handles, which
made corners hard to grab on small shapes.
### Code changes
| Section | LOC change |
| --------- | ---------- |
| Core code | +15 / -14 |
| Tests | +7 / -7 |
Closes tldraw#8840
Relates to tldraw#88391 parent 4170e5b commit 71ccc2a
2 files changed
Lines changed: 22 additions & 21 deletions
File tree
- packages/tldraw/src
- lib/overlays
- test/overlays
Lines changed: 15 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
245 | 244 | | |
246 | 245 | | |
247 | 246 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
252 | 253 | | |
253 | 254 | | |
254 | 255 | | |
| |||
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
272 | | - | |
| 273 | + | |
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
| |||
622 | 623 | | |
623 | 624 | | |
624 | 625 | | |
625 | | - | |
| 626 | + | |
626 | 627 | | |
627 | | - | |
628 | | - | |
629 | | - | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
630 | 631 | | |
631 | 632 | | |
632 | | - | |
| 633 | + | |
633 | 634 | | |
634 | | - | |
| 635 | + | |
635 | 636 | | |
636 | | - | |
| 637 | + | |
637 | 638 | | |
638 | | - | |
| 639 | + | |
639 | 640 | | |
640 | 641 | | |
641 | 642 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
110 | 109 | | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
0 commit comments