Fix panel ID logic and optimize state updates for hovered viewport panel

This commit is contained in:
2026-04-28 17:44:06 +02:00
parent 71ae447b3c
commit 7734fda48f

View File

@@ -3326,6 +3326,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
useRef<EditorSimulationController | null>(null); useRef<EditorSimulationController | null>(null);
const lastAutosaveErrorRef = useRef<string | null>(null); const lastAutosaveErrorRef = useRef<string | null>(null);
const viewportQuadSplitRef = useRef(editorState.viewportQuadSplit); const viewportQuadSplitRef = useRef(editorState.viewportQuadSplit);
const hoveredViewportPanelIdRef = useRef<ViewportPanelId | null>(null);
const lastPointerPositionRef = useRef<HierarchicalMenuPosition>({ const lastPointerPositionRef = useRef<HierarchicalMenuPosition>({
x: Math.round(window.innerWidth * 0.5), x: Math.round(window.innerWidth * 0.5),
y: Math.round(window.innerHeight * 0.5) y: Math.round(window.innerHeight * 0.5)
@@ -4749,15 +4750,18 @@ export function App({ store, initialStatusMessage }: AppProps) {
: null; : null;
const hoveredPanelId = const hoveredPanelId =
hoveredViewportPanelElement?.dataset.viewportPanelId; hoveredViewportPanelElement?.dataset.viewportPanelId;
const nextHoveredViewportPanelId =
setHoveredViewportPanelId(
hoveredPanelId === "topLeft" || hoveredPanelId === "topLeft" ||
hoveredPanelId === "topRight" || hoveredPanelId === "topRight" ||
hoveredPanelId === "bottomLeft" || hoveredPanelId === "bottomLeft" ||
hoveredPanelId === "bottomRight" hoveredPanelId === "bottomRight"
? hoveredPanelId ? hoveredPanelId
: null : null;
);
if (hoveredViewportPanelIdRef.current !== nextHoveredViewportPanelId) {
hoveredViewportPanelIdRef.current = nextHoveredViewportPanelId;
setHoveredViewportPanelId(nextHoveredViewportPanelId);
}
}; };
const handleWindowKeyDown = (event: globalThis.KeyboardEvent) => { const handleWindowKeyDown = (event: globalThis.KeyboardEvent) => {
@@ -4996,7 +5000,6 @@ export function App({ store, initialStatusMessage }: AppProps) {
editorState.selection, editorState.selection,
editorState.toolMode, editorState.toolMode,
entityList.length, entityList.length,
hoveredViewportPanelId,
layoutMode, layoutMode,
projectAssetStorage, projectAssetStorage,
projectAssetStorageReady, projectAssetStorageReady,