Skip to content

Commit 4e48bbe

Browse files
Merge 25.3 to 25.6
2 parents 2210001 + 3597932 commit 4e48bbe

5 files changed

Lines changed: 56 additions & 8 deletions

File tree

CageUI/src/client/cageui.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,17 @@ margin-bottom: 10px;
578578

579579
#utils {
580580
grid-area: room-utils;
581+
display: grid;
582+
grid-template-areas: "room-objects cage-templates .";
583+
}
584+
585+
.util-svg-template-wrapper {
586+
overflow: visible;
587+
}
588+
589+
590+
.layout-tooltip-container > * {
591+
padding: 10px;
581592
}
582593

583594
#layout-grid {

CageUI/src/client/components/layoutEditor/Editor.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ const Editor: FC<EditorProps> = ({roomSize}) => {
273273

274274
// Drag end for dragging from the utilities to the layout
275275
const dragEnded = useCallback(async (event) => {
276-
const draggedShape: d3.Selection<d3.BaseType, unknown, HTMLElement, any> = d3.select('.dragging');
276+
// clear transform attribute to prevent it from applying the transform while in groups. This was a change from Chrome 136 -> 137
277+
const draggedShape: d3.Selection<d3.BaseType, unknown, HTMLElement, any> = d3.select('.dragging').attr('transform', '');
277278
if(draggedShape.empty()) {
278279
dragLockRef.current = false;
279280
return;

CageUI/src/client/components/layoutEditor/RoomItemTemplate.tsx

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
import * as React from 'react';
20-
import { FC } from 'react';
20+
import { FC, useEffect, useRef, useState } from 'react';
2121
import { ActionURL } from '@labkey/api';
2222
import { RoomItemStringType } from '../../types/typings';
2323
import { ReactSVG } from 'react-svg';
@@ -28,16 +28,49 @@ interface RoomItemTemplateProps {
2828
}
2929
export const RoomItemTemplate: FC<RoomItemTemplateProps> = (props) => {
3030
const {fileName, className} = props;
31+
const imgRef = useRef(null);
32+
const [width, setWidth] = useState<string>("100%");
33+
const [height, setHeight] = useState<string>("100%");
34+
35+
// Effect reloads the svg to change the height and width of the wrapper for the requested svg after it is injected.
36+
// This ensures that it doesn't have a lot of empty space in between the svgs
37+
useEffect(() => {
38+
if (!imgRef.current) return;
39+
// Wait briefly for the nested SVG to render (adjust delay if needed)
40+
const timer = setTimeout(() => {
41+
const nestedSvg = imgRef.current?.reactWrapper.children[0].children[0];
42+
if (!nestedSvg) return;
43+
44+
// Method 1: Use explicit width/height (if nested SVG has them)
45+
const tempWidth = nestedSvg.getAttribute("width");
46+
const tempHeight = nestedSvg.getAttribute("height");
47+
48+
if (tempWidth && tempHeight) {
49+
setWidth(tempWidth);
50+
setHeight(tempHeight);
51+
}
52+
// Method 2: Fallback to rendered dimensions
53+
else {
54+
const rect = nestedSvg.getBoundingClientRect();
55+
setWidth(rect.width.toString());
56+
setHeight(rect.height.toString());
57+
}
58+
}, 100); // Short delay to ensure rendering
59+
60+
return () => clearTimeout(timer);
61+
}, []); // Empty dependency array = runs once after mount
62+
3163

3264
return (
3365
<div id={`${fileName}-template`}>
3466
<ReactSVG
3567
src={`${ActionURL.getContextPath()}/cageui/static/${fileName}.svg`}
3668
id={`${fileName}_template_wrapper`}
3769
wrapper={'svg'}
38-
className={className}
39-
width={'250'}
40-
height={'250'}
70+
ref={imgRef}
71+
height={height}
72+
width={width}
73+
className={className + " util-svg-template-wrapper"}
4174
/>
4275
</div>
4376
);

CageUI/src/client/context/LayoutEditorContextManager.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,8 @@ export const LayoutEditorContextProvider: FC<LayoutContextProps> = ({children, p
11131113
objects: []
11141114
}
11151115
});
1116+
setUnitLocs(createEmptyUnitLoc());
1117+
setNextAvailGroup('rack-group-1');
11161118
}
11171119

11181120
const saveRoom = async (): Promise<LayoutSaveResult> => {

CageUI/src/client/utils/LayoutEditorHelpers.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export const updateGrid = (transform, width, height, gridSize) => {
150150
const yMax = Math.ceil((height - transform.y) / transform.k / gridSize) * gridSize;
151151

152152
// Draw the grid within the current visible area
153-
for (let x = xMin; x <= xMax; x += gridSize) {
154-
for (let y = yMin; y <= yMax; y += gridSize) {
153+
for (let x = xMin; x < xMax; x += gridSize) {
154+
for (let y = yMin; y < yMax; y += gridSize) {
155155
g.append("rect")
156156
.attr("x", x)
157157
.attr("y", y)
@@ -734,8 +734,9 @@ export function createDragInLayout() {
734734
const element = d3.select(this);
735735
const transform = d3.zoomTransform(layoutSvg.node());
736736
const scale = transform.k;
737+
const [newX, newY] = d3.pointer(event.sourceEvent, this.parentNode);
737738

738-
element.attr('transform', `translate(${event.x},${event.y}) scale(${scale})`);
739+
element.attr('transform', `translate(${newX},${newY}) scale(${scale})`);
739740
}
740741
)
741742
}

0 commit comments

Comments
 (0)