From 0203b19ee5a7f2e51792ff50b927d47436990a72 Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Tue, 28 Jul 2026 15:49:25 +0200 Subject: [PATCH] =?UTF-8?q?fix(canvas):=20el=20chequeo=20de=20asiento=20se?= =?UTF-8?q?=20repite=20tras=20montar=20=E2=80=94=20el=20primer=20render=20?= =?UTF-8?q?lo=20congelaba?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isBoardSeated lee pinInfo/boardSocket del DOM; en el primer render de un ejemplo que ABRE con la placa ya posada ni la placa ni el zocalo estan montados, el memo devolvia 'no posada' y no recalculaba nunca (z=0 pese a asiento exacto medido). Re-chequeo al siguiente frame y a los 400ms. --- .../src/components/simulator/BoardOnCanvas.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/simulator/BoardOnCanvas.tsx b/frontend/src/components/simulator/BoardOnCanvas.tsx index 42954e97..aa6eb4da 100644 --- a/frontend/src/components/simulator/BoardOnCanvas.tsx +++ b/frontend/src/components/simulator/BoardOnCanvas.tsx @@ -109,9 +109,23 @@ export const BoardOnCanvas = ({ // stacking below. Recomputed on every position change; the check is a few // pad lookups over the component list, cheap at render rate. const components = useSimulatorStore((st) => st.components); + // The seat check reads pinInfo/boardSocket off DOM elements; on the FIRST + // render neither this board nor the socket component is mounted yet, so + // the memo would freeze on "not seated" for an example that OPENS with the + // board already stacked. Re-check after mount, twice: next frame, and once + // more after custom-element upgrade has had time to land. + const [seatEpoch, setSeatEpoch] = React.useState(0); + React.useEffect(() => { + const raf = requestAnimationFrame(() => setSeatEpoch((n) => n + 1)); + const t = setTimeout(() => setSeatEpoch((n) => n + 1), 400); + return () => { + cancelAnimationFrame(raf); + clearTimeout(t); + }; + }, []); const seated = React.useMemo( () => isBoardSeated(id, boardKind, x, y, components), - [id, boardKind, x, y, components], + [id, boardKind, x, y, components, seatEpoch], ); // Status dot color: green=running, amber=compiled, gray=idle