Skip to content

Commit 5927881

Browse files
Merge 25.11 to 26.3
2 parents e74b0f0 + ee476ab commit 5927881

5 files changed

Lines changed: 61 additions & 74 deletions

File tree

CageUI/ios-webpack/watch.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const constants = require('./constants');
2222
const path = require('path');
2323
// relative to the <lk_module>/node_modules/@labkey/build/webpack dir
2424
const entryPoints = require('../src/client/entryPoints.js');
25-
const host = require("host");
25+
const host = require("./host");
2626

2727

2828
const devServer = {

CageUI/resources/web/CageUI/static/legend.svg

Lines changed: 10 additions & 57 deletions
Loading

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

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const EditorContextMenu: FC<EditorContextMenuProps> = (props) => {
6464
type
6565
} = props;
6666

67-
const menuRef = useRef(null);
67+
const menuRef = useRef<HTMLDivElement>(null);
6868

6969
// Delete object for room objects
7070
const handleDeleteObject = (e: React.MouseEvent<HTMLElement>) => {
@@ -97,7 +97,44 @@ export const EditorContextMenu: FC<EditorContextMenuProps> = (props) => {
9797
return () => {
9898
document.removeEventListener('mousedown', handleClickOutside);
9999
};
100-
}, [menuRef]);
100+
}, [closeMenu]);
101+
102+
// Handle dynamic positioning
103+
useEffect(() => {
104+
if (!menuRef.current || ctxMenuStyle.display !== 'block') return;
105+
106+
const menu = menuRef.current;
107+
const { top, left } = ctxMenuStyle;
108+
const topValue = parseInt(top, 10);
109+
const leftValue = parseInt(left, 10);
110+
111+
const windowWidth = window.innerWidth;
112+
const windowHeight = window.innerHeight;
113+
const menuWidth = menu.offsetWidth;
114+
const menuHeight = menu.offsetHeight;
115+
116+
let adjustedTop = topValue;
117+
let adjustedLeft = leftValue;
118+
119+
// Prevent overflow to the right
120+
if (leftValue + menuWidth > windowWidth) {
121+
adjustedLeft = windowWidth - menuWidth - 10;
122+
}
123+
124+
// Prevent overflow to the bottom
125+
if (topValue + menuHeight > windowHeight) {
126+
adjustedTop = windowHeight - menuHeight - 10;
127+
}
128+
129+
// Prevent overflow to the left
130+
if (adjustedLeft < 10) adjustedLeft = 10;
131+
132+
// Prevent overflow to the top
133+
if (adjustedTop < 10) adjustedTop = 10;
134+
135+
menu.style.left = `${adjustedLeft}px`;
136+
menu.style.top = `${adjustedTop}px`;
137+
}, [ctxMenuStyle.display, ctxMenuStyle.left, ctxMenuStyle.top]);
101138

102139
return (
103140
<div id="contextMenu" className="context-menu" ref={menuRef} style={{

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,11 @@ export const RoomSelectorPopup: FC<RoomSelectorPopup> = (props) => {
7272
}
7373

7474
if (templateName.length > 0) {
75-
//return if new name doesn't have word template in it
76-
if (!templateName.includes('template')) {
77-
onCancel();
78-
return;
79-
}
75+
const newTemplateName = "template-" + templateName;
8076
// if template, save old template name for later
8177
setRoom(prevState => ({
8278
...prevState,
83-
name: templateName
79+
name: newTemplateName
8480
}));
8581
templateRename(selectedRoom);
8682
} else {
@@ -109,7 +105,7 @@ export const RoomSelectorPopup: FC<RoomSelectorPopup> = (props) => {
109105
</label>
110106
<input
111107
value={templateName}
112-
onChange={(e) => setTemplateName("template-" + e.target.value)}
108+
onChange={(e) => setTemplateName(e.target.value)}
113109
/>
114110
</div>
115111
}

CageUI/src/client/utils/helpers.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -758,20 +758,21 @@ export const buildNewLocalRoom = async (prevRoom: PrevRoom): Promise<[Room, Unit
758758
cageNumType = roomItemToString(defaultTypeToRackType(rackItem.objectType as DefaultRackTypes));
759759
}
760760

761-
let cageMods: CageModificationsType = {
762-
[ModLocations.Top]: [],
763-
[ModLocations.Bottom]: [],
764-
[ModLocations.Left]: [],
765-
[ModLocations.Right]: [],
766-
[ModLocations.Direct]: []
767-
};
761+
let cageMods: CageModificationsType;
768762
if (rackItem.extraContext) {
769763
extraContext = JSON.parse(rackItem.extraContext);
770764
}
771765
const svgSize = await getSvgSize(rack.type.type);
772766

773767
// This is where mods are loaded into state for the room
774768
if (loadMods && !rack.type.isDefault) {
769+
cageMods = {
770+
[ModLocations.Top]: [],
771+
[ModLocations.Bottom]: [],
772+
[ModLocations.Left]: [],
773+
[ModLocations.Right]: [],
774+
[ModLocations.Direct]: []
775+
};
775776

776777
const modReturnData = await cageModLookup([], []);
777778
const availMods = modReturnData.map(row => ({value: row.value, label: row.title}));

0 commit comments

Comments
 (0)