Refuse a placement aimed at the toolbar, and say why (#33) #1124

Merged
jaylouisw merged 1 commit from fix/place-under-toolbar into main 2026-11-08 20:22:52 +00:00
Owner

The toolbar is HTML floating over the drawing surface. A press that starts on the canvas and is released over the toolbar still arrives at the SVG — pointer capture keeps sending it there — so the app placed the device at those coordinates. The device existed on the server, was painted on the drawing, and sat underneath the panel, where it could not be clicked, dragged or deleted. From the user's side the drop worked and the device vanished.

The fix

Placement now asks the document what is actually at that pixel:

if (elementCoversPoint(pointElement(e.clientX, e.clientY), svg)) {
  on.placeBlocked(w.x, w.y, state.placing);   // report, do not place
} else {
  on.place(w.x, w.y, state.placing);
}

Anything that is not the SVG, and not inside it, is an overlay, and a placement aimed at an overlay places nothing. The user is told — "was not placed: that spot is under the toolbar. Click the canvas." — and placing mode stays armed, so the next click works without reselecting the device from the palette.

Why the rule is testable

elementCoversPoint is pure and exported as PFCanvas.elementCoversPoint, so the interesting cases run without a browser: the toolbar blocks, a device inside the surface does not, the surface itself does not, nothing reported does not block on a guess, and a throwing elementFromPoint is survivable (feature-detected, wrapped).

21 checks — the rule, the placement branch, the callback table, and that app.js toasts the cause without disarming placing mode.

Full suite: 112 suites, 4968 assertions, 0 failed. Closes #33.

The toolbar is HTML floating over the drawing surface. A press that starts on the canvas and is released over the toolbar **still arrives at the SVG** — pointer capture keeps sending it there — so the app placed the device at those coordinates. The device existed on the server, was painted on the drawing, and sat underneath the panel, where it could not be clicked, dragged or deleted. From the user's side the drop worked and the device vanished. ### The fix Placement now asks the document what is actually at that pixel: ```js if (elementCoversPoint(pointElement(e.clientX, e.clientY), svg)) { on.placeBlocked(w.x, w.y, state.placing); // report, do not place } else { on.place(w.x, w.y, state.placing); } ``` Anything that is not the SVG, and not inside it, is an overlay, and a placement aimed at an overlay places nothing. The user is told — *"was not placed: that spot is under the toolbar. Click the canvas."* — and **placing mode stays armed**, so the next click works without reselecting the device from the palette. ### Why the rule is testable `elementCoversPoint` is pure and exported as `PFCanvas.elementCoversPoint`, so the interesting cases run without a browser: the toolbar blocks, a device inside the surface does not, the surface itself does not, *nothing reported* does not block on a guess, and a throwing `elementFromPoint` is survivable (feature-detected, wrapped). **21 checks** — the rule, the placement branch, the callback table, and that `app.js` toasts the cause without disarming placing mode. Full suite: 112 suites, 4968 assertions, 0 failed. Closes #33.
Refuse a placement aimed at the toolbar, and say why (#33)
Some checks failed
CI / Test (Node 20) (pull_request) Successful in 1m38s
CI / Test (Node 18) (pull_request) Successful in 1m42s
CI / Server smoke test (pull_request) Successful in 31s
CI / Docker build (pull_request) Successful in 48s
CI / Test (Node 22) (pull_request) Successful in 1m40s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Failing after 18s
4f155021d0
The toolbar is HTML floating over the drawing surface. A press that starts on the canvas
and is released over the toolbar still arrives at the SVG — pointer capture keeps sending
it there — so the app placed the device at those coordinates. The device existed on the
server, was painted on the drawing, and sat underneath the panel, where it could not be
clicked, dragged or deleted. From the user's side the drop worked and the device vanished.

Placement now asks the document what is actually at that pixel. Anything that is not the
SVG, and not inside it, is an overlay, and a placement aimed at an overlay places nothing.
The user is told — "was not placed: that spot is under the toolbar" — and placing mode
stays armed, so the next click on the canvas works without reselecting the device.

The rule is pure and exported as `PFCanvas.elementCoversPoint`, so it is tested without a
browser: the toolbar blocks, a device inside the surface does not, the surface itself does
not, nothing-reported does not block on a guess, and a throwing `elementFromPoint` is
survivable. 21 checks, plus the wiring on both sides.

Closes #33.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1124
No description provided.