fix: gridstack not working (#642)
* fix: gridstack not working * chore: remove unneccessary comments
This commit is contained in:
@@ -54,15 +54,19 @@ export const useGridstack = ({ section, mainRef }: UseGridstackProps): UseGrista
|
|||||||
const onChange = useCallback(
|
const onChange = useCallback(
|
||||||
(changedNode: GridStackNode) => {
|
(changedNode: GridStackNode) => {
|
||||||
const itemId = changedNode.el?.getAttribute("data-id");
|
const itemId = changedNode.el?.getAttribute("data-id");
|
||||||
if (!itemId || !changedNode.x || !changedNode.y || !changedNode.w || !changedNode.h) return;
|
if (!itemId) return;
|
||||||
|
|
||||||
// Updates the react-query state
|
// Updates the react-query state
|
||||||
moveAndResizeItem({
|
moveAndResizeItem({
|
||||||
itemId,
|
itemId,
|
||||||
xOffset: changedNode.x,
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
yOffset: changedNode.y,
|
xOffset: changedNode.x!,
|
||||||
width: changedNode.w,
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
height: changedNode.h,
|
yOffset: changedNode.y!,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
width: changedNode.w!,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
height: changedNode.h!,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[moveAndResizeItem],
|
[moveAndResizeItem],
|
||||||
@@ -70,16 +74,20 @@ export const useGridstack = ({ section, mainRef }: UseGridstackProps): UseGrista
|
|||||||
const onAdd = useCallback(
|
const onAdd = useCallback(
|
||||||
(addedNode: GridStackNode) => {
|
(addedNode: GridStackNode) => {
|
||||||
const itemId = addedNode.el?.getAttribute("data-id");
|
const itemId = addedNode.el?.getAttribute("data-id");
|
||||||
if (!itemId || !addedNode.x || !addedNode.y || !addedNode.w || !addedNode.h) return;
|
if (!itemId) return;
|
||||||
|
|
||||||
// Updates the react-query state
|
// Updates the react-query state
|
||||||
moveItemToSection({
|
moveItemToSection({
|
||||||
itemId,
|
itemId,
|
||||||
sectionId: section.id,
|
sectionId: section.id,
|
||||||
xOffset: addedNode.x,
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
yOffset: addedNode.y,
|
xOffset: addedNode.x!,
|
||||||
width: addedNode.w,
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
height: addedNode.h,
|
yOffset: addedNode.y!,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
width: addedNode.w!,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
height: addedNode.h!,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[moveItemToSection, section.id],
|
[moveItemToSection, section.id],
|
||||||
|
|||||||
Reference in New Issue
Block a user