mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
🐛 Fix issue with edit mode resizing
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { GridItemHTMLElement, GridStack, GridStackNode } from 'fily-publish-gridstack';
|
import { GridItemHTMLElement, GridStack, GridStackNode } from 'fily-publish-gridstack';
|
||||||
import { MutableRefObject, RefObject } from 'react';
|
import { MutableRefObject, RefObject, useEffect } from 'react';
|
||||||
import { AppType } from '../../../../types/app';
|
import { AppType } from '../../../../types/app';
|
||||||
import { ShapeType } from '../../../../types/shape';
|
import { ShapeType } from '../../../../types/shape';
|
||||||
import { IWidget } from '../../../../widgets/widgets';
|
import { IWidget } from '../../../../widgets/widgets';
|
||||||
@@ -45,7 +45,7 @@ export const initializeGridstack = (
|
|||||||
);
|
);
|
||||||
const grid = newGrid.current;
|
const grid = newGrid.current;
|
||||||
// Must be used to update the column count after the initialization
|
// Must be used to update the column count after the initialization
|
||||||
grid.column(columnCount);
|
grid.column(columnCount, 'none');
|
||||||
|
|
||||||
// Add listener for moving items around in a wrapper
|
// Add listener for moving items around in a wrapper
|
||||||
grid.on('change', (_, el) => {
|
grid.on('change', (_, el) => {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useMantineTheme } from '@mantine/core';
|
import { useMantineTheme } from '@mantine/core';
|
||||||
import create from 'zustand';
|
import create from 'zustand';
|
||||||
import { useConfigContext } from '../../../../config/provider';
|
|
||||||
|
|
||||||
export const useGridstackStore = create<GridstackStoreType>((set, get) => ({
|
export const useGridstackStore = create<GridstackStoreType>((set, get) => ({
|
||||||
mainAreaWidth: null,
|
mainAreaWidth: null,
|
||||||
|
|||||||
@@ -232,6 +232,11 @@ export const useGridstack = (
|
|||||||
|
|
||||||
// initialize the gridstack
|
// initialize the gridstack
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const removeEventHandlers = () => {
|
||||||
|
gridRef.current?.off('change');
|
||||||
|
gridRef.current?.off('added');
|
||||||
|
};
|
||||||
|
|
||||||
const tilesWithUnknownLocation: TileWithUnknownLocation[] = [];
|
const tilesWithUnknownLocation: TileWithUnknownLocation[] = [];
|
||||||
initializeGridstack(
|
initializeGridstack(
|
||||||
areaType,
|
areaType,
|
||||||
@@ -250,7 +255,7 @@ export const useGridstack = (
|
|||||||
onAdd,
|
onAdd,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (!configName) return;
|
if (!configName) return removeEventHandlers;
|
||||||
updateConfig(configName, (prev) => ({
|
updateConfig(configName, (prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
apps: prev.apps.map((app) => {
|
apps: prev.apps.map((app) => {
|
||||||
@@ -300,6 +305,7 @@ export const useGridstack = (
|
|||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
return removeEventHandlers;
|
||||||
}, [items, wrapperRef.current, widgets, wrapperColumnCount]);
|
}, [items, wrapperRef.current, widgets, wrapperColumnCount]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user