Cables paint over devices and their invisible hit areas block ports - sockets under a cable cannot be clicked #2
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge#2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Cables are rendered after the devices inside
#world, so every cable paints on top of every device — and the invisible click target for each cable (line.link-hit) sits over the port sockets. Once a router has a couple of cables attached, the rest of its ports become unclickable: clicking a socket selects the cable that happens to cross it instead.This makes it impossible to fully cable any device that already has a link.
Evidence
#worldchild order — all eleven device groups come first, then the link lines:Because SVG paints in document order, every
lineis drawn above every device group.Ports that are now unclickable
elementFromPointat each port dot's centre on the router (d3, RT-AX89X), which had four cables attached at the time:Five of twelve sockets on this router are dead to the mouse. Attempting to click
lan3does not arm a connection — status stays idle, nothing is sent, no error is shown. Same silent failure as #61, different cause.There is nothing on screen to indicate why: the cables are thin lines that visually pass near the sockets, and the blocking element is an invisible fat stroke.
Why it happens
Two separate faults combine:
#worldafter the devices (see the child order above), so they paint over the faceplates. Cables should sit below devices — a cable running across a device body should disappear behind it, which is also how the device currently gets visually clipped.line.link-hitis a wide transparent stroke used as a click target for selecting a cable, and it inherits the same stacking position — above the ports. A 2 px visible cable is backed by a hit area several pixels wide, easily wide enough to cover a 6–10 px socket.Reproduction
Link: ...).Suggested fix
Give links their own layer, inserted before the device groups:
then append cables into
linksLayerinstead ofworld. That fixes both the visual clipping and the hit-testing in one move.Additionally:
.link { pointer-events: none; }— the visible stroke should never be clickable.line.link-hitas the click target, but put it in the samelinksLayer(so it is below the devices and therefore below the ports), and narrow it to roughlystroke-width: 6rather than something that can span a whole faceplate.Impact
Notes
Fixed, and it took two changes because the report contains two defects:
web/canvas.jsnow builds two explicit layers,cable-layerthendevice-layer, so cables paint behind devices instead of over the faceplate.e.target.closest(...), so whatever the browser painted last at that pixel decided what the mouse hit. It is now explicit geometry with a precedence: port, then device body, then cable, then background. Reordering the DOM alone would have moved which element was in the way, not removed it.test/canvas-hit-testing.test.js(27 checks) drives real pointerdown events at the coordinates of a socket with a cable drawn over it and asserts which handler ran, plus the paint order of the resulting drawing.