fix(canvas): el chequeo de asiento se repite tras montar — el primer render lo congelaba
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.
This commit is contained in:
parent
3ca8bf0e6e
commit
0203b19ee5
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue