Skip to content

Commit

Permalink
Draggable grid fixes (#11944)
Browse files Browse the repository at this point in the history
* Use globals on grid for resizing/dragging flags

* remove unneeded useeffect
  • Loading branch information
hawkeye217 committed Jun 13, 2024
1 parent e56ce99 commit 349b27b
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions web/src/views/live/DraggableGridLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ export default function DraggableGridLayout({
const [showCircles, setShowCircles] = useState(true);

useEffect(() => {
setIsEditMode(false);
setEditGroup(false);
}, [cameraGroup]);
}, [cameraGroup, setIsEditMode]);

// camera state

Expand Down Expand Up @@ -185,8 +186,6 @@ export default function DraggableGridLayout({
y: 0, // don't set y, grid does automatically
w: width,
h: height,
isDraggable: isEditMode,
isResizable: isEditMode,
};

optionsMap.push(options);
Expand All @@ -195,31 +194,12 @@ export default function DraggableGridLayout({
return optionsMap;
}, [
cameras,
isEditMode,
isGridLayoutLoaded,
currentGridLayout,
includeBirdseye,
birdseyeConfig,
]);

useEffect(() => {
if (currentGridLayout) {
const updatedGridLayout = currentGridLayout.map((layout) => ({
...layout,
isDraggable: isEditMode,
isResizable: isEditMode,
}));
if (isEditMode) {
setGridLayout(updatedGridLayout);
setCurrentGridLayout(updatedGridLayout);
} else {
setGridLayout(updatedGridLayout);
}
}
// we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isEditMode, setGridLayout]);

useEffect(() => {
if (isGridLayoutLoaded) {
if (gridLayout) {
Expand Down Expand Up @@ -406,6 +386,8 @@ export default function DraggableGridLayout({
onResize={handleResize}
onResizeStart={() => setShowCircles(false)}
onResizeStop={handleLayoutChange}
isDraggable={isEditMode}
isResizable={isEditMode}
>
{includeBirdseye && birdseyeConfig?.enabled && (
<BirdseyeLivePlayerGridItem
Expand Down

0 comments on commit 349b27b

Please sign in to comment.