From eb0ff9c2b2460ed6d79a21ab845a67c55bc652e0 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 13 Nov 2026 20:21:31 +0000 Subject: [PATCH] =?UTF-8?q?[239]=20Abschnitts-Rahmen=20der=20Objekt-Info?= =?UTF-8?q?=20ohne=20eigene=20Komponente=20f=C3=BCr=20Bezugspunkt/Masse/Ge?= =?UTF-8?q?l=C3=A4nde:=20Render-Z=C3=A4hlung=20je=20Wand-=C3=84nderung=20w?= =?UTF-8?q?ieder=2043=20statt=2045=20[121]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/panels/ObjectInfoPanel.tsx | 20 ++++++++------- src/panels/objectInfo/InfoGroup.tsx | 38 ++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/panels/ObjectInfoPanel.tsx b/src/panels/ObjectInfoPanel.tsx index 171edce2..71f3e32d 100644 --- a/src/panels/ObjectInfoPanel.tsx +++ b/src/panels/ObjectInfoPanel.tsx @@ -36,7 +36,7 @@ import { ViewShadowsInfo, MeasurementSection } from "./objectInfo/InfoBlocks"; import { DimensionField, RotateField } from "./objectInfo/fields"; import { elementDimensions } from "./objectInfo/elementDims"; import { InfoGroups, hasInfoGroups } from "./objectInfo/InfoGroups"; -import { InfoGroup } from "./objectInfo/InfoGroup"; +import { infoGroupFrame, useInfoGroupState } from "./objectInfo/InfoGroup"; // ── Bezugspunkt-Raster ─────────────────────────────────────────────────────── // Neun Anker als 3×3-Raster. Zeile 0 = oben (fy=0), Spalte 0 = links (fx=0). @@ -63,6 +63,8 @@ function toDeg360(rad: number): number { export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: boolean } = {}) { const host = usePanelHost(); const storeProject = useStore((st) => st.project); + // [121] Abschnitts-Rahmen ohne eigene Komponente (kein Render je Abschnitt bei Inhaltsänderung). + const gst = useInfoGroupState(); const sel = useSelectionInfo(); // Gewählter Bezugspunkt — Default Mitte (Vectorworks-Standardanker beim @@ -194,7 +196,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool {showPlacement && ( <> - + {infoGroupFrame(gst, "refpoint", <> {/* Bezugspunkt-Würfel (3×3, immer quadratisch) links, X/Y/Z als Spalte rechts daneben (Nutzer-Wunsch). */}
@@ -248,9 +250,9 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool host.onRotateSelectionAround(px, py, deg)} />
-
+ )} - + {infoGroupFrame(gst, "dimensions", <> {/* Maße (editierbar) — Commit auf blur/Enter skaliert um den Anker. */} {elementDims ? ( // [204a] Wand: Länge/Dicke/Höhe, Öffnung: Breite/Höhe/Brüstung (nur Anzeige). @@ -351,7 +353,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool /> )} - + )} )} {/* Gelände-/Umgebungs-Element (Netzkörper, Gelände, Höhenlinien …): Art, Herkunft (nur Auskunft, [181]), @@ -359,7 +361,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool georeferenziert importiert wurde (Nutzer-Wunsch zum Prüfen). */} {sel.contextObject && ( <> - + {infoGroupFrame(gst, "contextProps", <>
{t("objinfo.contextObject.type")} {t(`objinfo.contextObject.type.${sel.contextObject.objType}`)} @@ -369,9 +371,9 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
)} -
+ )} {/* [239] Herkunft und LV95 stehen in eigener Gruppe (Standard zugeklappt: nur Auskunft). */} - + {infoGroupFrame(gst, "georef", <> {sel.contextObject.source && (
{t("objinfo.contextObject.source")} @@ -394,7 +396,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool {t("objinfo.contextObject.noAnchor")}
)} -
+ )} )} {/* [189] Bauteil-/BIM-Abschnitte (Wand, Decke, Öffnung, Treppe, Raum …) als einklappbare Gruppen. */} diff --git a/src/panels/objectInfo/InfoGroup.tsx b/src/panels/objectInfo/InfoGroup.tsx index 0f925145..b7a09073 100644 --- a/src/panels/objectInfo/InfoGroup.tsx +++ b/src/panels/objectInfo/InfoGroup.tsx @@ -1,25 +1,34 @@ // [189] Einklappbarer Abschnitt der Objekt-Info: Kopfzeile (Knopf mit Pfeil) und Inhalt. Die Abschnitts- // Komponenten (`WallSection` …) bringen ihre eigene Kopf-Trennlinie mit; die erste blendet das CSS im Rumpf aus. -import { useEffect, useRef, useSyncExternalStore, type ReactNode } from "react"; +import { useSyncExternalStore, type ReactNode } from "react"; import { t } from "../../i18n"; import { INFO_GROUP_TITLE, type InfoGroupId } from "./groups"; import { clearInfoGroupFocus, getInfoGroupState, isInfoGroupOpen, subscribeInfoGroups, toggleInfoGroup } from "./infoGroupState"; -export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNode }) { - const st = useSyncExternalStore(subscribeInfoGroups, getInfoGroupState, getInfoGroupState); +type GroupState = ReturnType; + +/** Zustand der Abschnitte (offen/zu, Fokus-Anfrage) für [`infoGroupFrame`]. */ +export function useInfoGroupState(): GroupState { + return useSyncExternalStore(subscribeInfoGroups, getInfoGroupState, getInfoGroupState); +} + +/** + * Abschnitt als blosses Markup, ohne eigene Komponente: Das Panel liest den Zustand einmal ([`useInfoGroupState`]) + * und rahmt damit mehrere Abschnitte, ohne dass je Abschnitt ein Komponenten-Render bei jeder Änderung des Inhalts + * anfällt ([121], Render-Zählung). Die Fokus-Anfrage löst der Ref des Kopfknopfs ein. + */ +export function infoGroupFrame(st: GroupState, id: InfoGroupId, children: ReactNode): ReactNode { const open = isInfoGroupOpen(st, id); - const head = useRef(null); - useEffect(() => { - if (st.focus?.id !== id) return; - head.current?.scrollIntoView?.({ block: "nearest" }); - head.current?.focus(); - clearInfoGroupFocus(); - }, [st.focus, id]); return ( -
+
); } + +export function InfoGroup({ id, children }: { id: InfoGroupId; children: ReactNode }) { + const st = useInfoGroupState(); + return infoGroupFrame(st, id, children); +}