velxio/frontend/src
David Montero Crespo 81ac2283c6 fix(canvas): wires follow components on rotation
Rotating a part with the 90° button used to leave every wire pinned to
the pre-rotation pixel coordinates — the component visually unhooked
from its cables. Two paths were missing:

  1. useSimulatorStore.updateComponent only triggered updateWirePositions
     for x/y changes. A rotation went through properties.rotation, so
     wires never recomputed.
  2. calculatePinPosition didn't know about rotation. Even when called,
     it returned the unrotated offset, so the new endpoints would still
     have been wrong.
  3. recordRotate (undo/redo) skipped updateWirePositions on both legs,
     so Ctrl+Z after a rotate left the canvas inconsistent.

Fix:

  - calculatePinPosition gets a 5th `rotation` argument. When non-zero,
    it finds the .dynamic-component-wrapper ancestor in the DOM, reads
    its offsetWidth/Height (layout-only, immune to CSS transforms) to
    locate the wrapper centre, and applies a 2D rotation matrix around
    that pivot. The wrapper top-left is recovered as (componentX - 4,
    componentY - 6) to match the offset convention updateWirePositions
    already uses.
  - updateWirePositions and recalculateAllWirePositions read the per-
    component rotation and thread it through.
  - updateComponent recomputes wires whenever properties.rotation
    changes, mirroring the existing x/y path.
  - recordRotate.execute and .undo both call updateWirePositions so
    Ctrl+Z keeps the canvas coherent.

Tests (pin-position-rotation.test.ts, 6 cases): unrotated identity,
90° (left edge → bottom), 180° (point reflection), 360° round-trip,
negative angles, and a store-level integration that rotates a fake
component and asserts wires[0].start moves to the rotated coordinate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 18:03:32 -03:00
..
__pro_stub__
__tests__ fix(canvas): wires follow components on rotation 2026-05-12 18:03:32 -03:00
assets
components Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
data Add HD44780Decoder and various I2C sketches 2026-05-12 14:26:33 -03:00
hooks
i18n feat(simulator): wire color palette from PR #170 + Copilot suggestions 2026-05-11 12:14:36 -03:00
pages feat(auth): welcome email on register + password reset via Odoo mail relay 2026-05-12 17:34:30 -03:00
services feat(auth): welcome email on register + password reset via Odoo mail relay 2026-05-12 17:34:30 -03:00
simulation feat(i2c): cross-board bridging across all velxio boards (AVR/RP2040/ESP32 xtensa+riscv) 2026-05-12 17:51:39 -03:00
store fix(canvas): wires follow components on rotation 2026-05-12 18:03:32 -03:00
tokens
types
utils fix(canvas): wires follow components on rotation 2026-05-12 18:03:32 -03:00
velxio-elements
App.css
App.tsx feat(auth): welcome email on register + password reset via Odoo mail relay 2026-05-12 17:34:30 -03:00
entry-server.tsx
index.css feat(auth): welcome email on register + password reset via Odoo mail relay 2026-05-12 17:34:30 -03:00
main.tsx Potential fix for pull request finding 2026-05-11 11:36:51 -03:00
seoRoutes.ts
vite-env.d.ts