Fix QR code Y-offset drift and 1-dot resize drift#4
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves coordinate handling during canvas transformations by introducing modelPositionFromRenderedTopLeft to correctly invert render-time offsets for specific object types like QR codes and ellipses. It also adds ignoreStroke to the transformer to prevent coordinate drift caused by stroke padding. I have provided feedback suggesting the use of Konva-specific methods for better type safety when accessing ellipse radii and the use of Math.abs() to ensure the coordinate calculation remains robust if objects are flipped.
Exclude selection stroke from the bbox to prevent sub-dot drift. Adjust Konva transformer logic to correctly calculate the rendered top-left for ellipses, which are center-anchored. Introduce a new utility function `modelPositionFromRenderedTopLeft` to handle per-object rendering offsets, specifically addressing the +10 dot Y-offset for QR codes when `positionType` is not 'FT'. This ensures accurate model position updates after transformations.
d2847f8 to
49e3706
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses coordinate drift and positioning inaccuracies during object transformation on the canvas. Key changes include adding the ignoreStroke property to the Konva transformer to exclude selection strokes from bounding box calculations and introducing a modelPositionFromRenderedTopLeft utility to correctly invert render-time offsets (such as the QR code Y-offset) when updating model positions. Comprehensive tests for the new utility were also added. I have no feedback to provide as there were no review comments to evaluate.
Two style fixes folded together:
- em-dashes in new comments and UI strings replaced with colon/semicolon
per repo writing-style convention; the Variable dropdown options now
read `{name}: "{default}"`.
- row-error cleanup uses rest-spread destructure instead of a manual
rebuild loop (Gemini PR-review suggestion #4). `void _drop`
satisfies the unused-var lint.
Summary
Two resize bugs not covered by #3:
BarcodeObjectadds a hardcoded+10dot Y-offset to QR codes (Zebra firmware artifact).handleDragEndalready inverts this, butonTransformEnddid not, so every resize accumulated a +10 dot drift in the stored model y.node.x()/y()that surfaced as 1-dot ZPL coordinate jumps afterpxToDotsrounding.Changes
modelPositionFromRenderedTopLeftintransformPosition.tsthat inverts per-type render offsets (currently QR FO+10dot Y). Mirrors the inversionBarcodeObject.handleDragEndalready does, so drag and resize stay consistent.useKonvaTransformer.onTransformEndcalls the helper aftertransformNodeTopLeft(Fix/jumping ellipse #3) and beforepositionDidMove-gated snap.ignoreStrokeon theTransformerso the bbox is the geometric shape, not the stroke-padded visual.Test plan
pnpm lintpnpm test(424 passed)npx tsc --noEmit