@topconsultnpm/sdkui-react 6.20.0-dev1.41 → 6.20.0-dev1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -236,6 +236,8 @@ const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], isConstrained
|
|
|
236
236
|
setState(s => ({ ...s, isDragging: true }));
|
|
237
237
|
};
|
|
238
238
|
const handleGripDoubleClick = () => {
|
|
239
|
+
if (state.isConfigMode)
|
|
240
|
+
return;
|
|
239
241
|
toggleOrientation();
|
|
240
242
|
};
|
|
241
243
|
const handleMouseMove = useCallback((e) => {
|
|
@@ -313,6 +315,58 @@ const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], isConstrained
|
|
|
313
315
|
}
|
|
314
316
|
});
|
|
315
317
|
};
|
|
318
|
+
// Auto-reposition when entering edit mode to ensure Apply/Undo buttons are visible
|
|
319
|
+
useEffect(() => {
|
|
320
|
+
if (!state.isConfigMode || !floatingRef.current)
|
|
321
|
+
return;
|
|
322
|
+
requestAnimationFrame(() => {
|
|
323
|
+
if (!floatingRef.current)
|
|
324
|
+
return;
|
|
325
|
+
const floating = floatingRef.current.getBoundingClientRect();
|
|
326
|
+
let newX = state.position.x;
|
|
327
|
+
let newY = state.position.y;
|
|
328
|
+
let needsUpdate = false;
|
|
329
|
+
if (isConstrained && containerRef.current) {
|
|
330
|
+
const container = containerRef.current.getBoundingClientRect();
|
|
331
|
+
if (state.orientation === 'horizontal') {
|
|
332
|
+
if (state.position.x + floating.width > container.width) {
|
|
333
|
+
newX = Math.max(0, container.width - floating.width);
|
|
334
|
+
needsUpdate = true;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
if (state.position.y + floating.height > container.height) {
|
|
339
|
+
newY = Math.max(0, container.height - floating.height);
|
|
340
|
+
needsUpdate = true;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
if (state.orientation === 'horizontal') {
|
|
346
|
+
if (state.position.x + floating.width > window.innerWidth) {
|
|
347
|
+
newX = Math.max(0, window.innerWidth - floating.width - 10);
|
|
348
|
+
needsUpdate = true;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
if (state.position.y + floating.height > window.innerHeight) {
|
|
353
|
+
newY = Math.max(0, window.innerHeight - floating.height - 10);
|
|
354
|
+
needsUpdate = true;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (needsUpdate) {
|
|
359
|
+
setState(s => ({
|
|
360
|
+
...s,
|
|
361
|
+
position: { x: newX, y: newY },
|
|
362
|
+
}));
|
|
363
|
+
// Update snapshot position to the corrected position so Undo restores to visible position
|
|
364
|
+
if (stateSnapshot.current) {
|
|
365
|
+
stateSnapshot.current.position = { x: newX, y: newY };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
}, [state.isConfigMode, state.orientation, isConstrained]);
|
|
316
370
|
const handleUndo = () => {
|
|
317
371
|
if (stateSnapshot.current) {
|
|
318
372
|
setState(s => ({
|
|
@@ -320,7 +374,7 @@ const TMFloatingMenuBar = ({ containerRef, contextMenuItems = [], isConstrained
|
|
|
320
374
|
items: [...stateSnapshot.current.items],
|
|
321
375
|
orientation: stateSnapshot.current.orientation,
|
|
322
376
|
position: { ...stateSnapshot.current.position },
|
|
323
|
-
isConfigMode: true,
|
|
377
|
+
isConfigMode: true,
|
|
324
378
|
}));
|
|
325
379
|
}
|
|
326
380
|
};
|