Freehand drawing moves when starting a selection over empty space inside its bounding box #222
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_whiteboard#222
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
In selection mode, starting a rubber-band selection (drag a selection rectangle) over the empty area inside a freehand drawing's bounding box grabs and moves the drawing instead of beginning a selection. The pointer is over blank canvas (no ink there), so it should start a selection — or, if anything, only move the drawing when the click is actually on the ink (or very close to it).
Steps to reproduce
Root cause
crates/hero_whiteboard_admin/static/web/js/whiteboard/objects.js,createDrawing(around line 2292):Konva.Rectnamedbgwithfill: 'transparent'.Proposed fix
bgrect non-listening (listening: false). It is only used for sizing;findOne('.bg')andgetClientRectstill work on non-listening nodes, so culling/snap/bounds are unaffected. With the bg out of the hit graph, only the actual ink lines capture hits.hitStrokeWidth(e.g.Math.max(strokeWidth, 12)) so the drawing can still be grabbed when the press is on or very close to the ink, without requiring pixel precision.Acceptance criteria
Implementation Spec for Issue #222
Objective
A freehand drawing must only be grabbed/moved when the pointer is on its ink (or very close to it), not anywhere inside its bounding box. Starting a drag from empty space inside the bbox should begin a rubber-band selection.
Root cause
createDrawing(crates/hero_whiteboard_admin/static/web/js/whiteboard/objects.js, ~line 2292) adds a full-bboxKonva.Rectnamedbgwithfill: 'transparent'. Transparent-fill rects still register pointer hits in Konva, so the whole bbox is a drag target, pre-empting the stage rubber-band selection.Files to Modify
crates/hero_whiteboard_admin/static/web/js/whiteboard/objects.js-createDrawing(bg rect) and_rebuildDrawingLines(line hit width)Implementation Plan
Step 1: Take the drawing's bbox rect out of the hit graph
Files:
crates/hero_whiteboard_admin/static/web/js/whiteboard/objects.jscreateDrawing, addlistening: falseto thebgKonva.Rect.findOne('.bg'),getClientRect, snapping and viewport culling all work on non-listening nodes, so bounds behaviour is unchanged.Dependencies: none
Step 2: Give the ink lines a comfortable hit margin
Files:
crates/hero_whiteboard_admin/static/web/js/whiteboard/objects.js_rebuildDrawingLines, sethitStrokeWidth: Math.max(strokeWidth, 12)on each line config so the drawing can still be grabbed when the press is on or very close to the ink, without pixel precision. (Defaultautomakes the hit area equal to the thin stroke width.)Dependencies: none (independent of Step 1)
Acceptance Criteria
Notes
node --checkof the whiteboard JS plus a manual check.Implementation Summary
Changes
crates/hero_whiteboard_admin/static/web/js/whiteboard/objects.js:createDrawing- the invisible full-bboxbgrect is now created withlistening: false. It stays available for sizing/bounds (findOne('.bg'),getClientRect, snapping, culling all work on non-listening nodes), but it no longer captures pointer hits, so the empty space inside a drawing's bounding box is no longer a drag target._rebuildDrawingLines- each ink line now setshitStrokeWidth: Math.max(strokeWidth, 12), so the drawing can still be grabbed when the press is on or very close to the ink without requiring pixel precision.Net effect: pressing empty space inside the bbox starts a rubber-band selection; pressing on/near the ink grabs and moves the drawing.
Verification
node --check- all pass.Acceptance criteria
Adjustment: the ink hit margin was increased from
max(strokeWidth, 12)tomax(strokeWidth, 24)(about 12px of slack on each side of the stroke). 12 required pressing almost exactly on the ink; 24 lets a near-the-ink press grab the drawing, while far-empty areas inside the bounding box still start a rubber-band selection.