diff --git a/frontend/src/Editor/Container.jsx b/frontend/src/Editor/Container.jsx index 10e9e63e23..98a2cf6382 100644 --- a/frontend/src/Editor/Container.jsx +++ b/frontend/src/Editor/Container.jsx @@ -13,7 +13,6 @@ import config from 'config'; import Spinner from '@/_ui/Spinner'; import { useHotkeys } from 'react-hotkeys-hook'; import { addComponents, addNewWidgetToTheEditor, isPDFSupported } from '@/_helpers/appUtils'; -import { useCurrentState } from '@/_stores/currentStateStore'; import { useAppVersionStore } from '@/_stores/appVersionStore'; import { useEditorStore } from '@/_stores/editorStore'; import { useAppInfo } from '@/_stores/appDataStore'; @@ -31,7 +30,7 @@ import { useDraggedSubContainer, useGridStore } from '@/_stores/gridStore'; const deviceWindowWidth = EditorConstants.deviceWindowWidth; export const Container = ({ - canvasWidth, + widthOfCanvas, mode, snapToGrid, onComponentClick, @@ -72,10 +71,13 @@ export const Container = ({ shallow ); + const canvasWidth = widthOfCanvas + ? widthOfCanvas + : document.getElementsByClassName('canvas-area')[0]?.getBoundingClientRect()?.width; const gridWidth = canvasWidth / noOfGrids; + const { appId } = useAppInfo(); - const currentState = useCurrentState(); const { appVersionsId, isVersionReleased } = useAppVersionStore( (state) => ({ appVersionsId: state?.editingVersion?.id, @@ -762,7 +764,6 @@ export const Container = ({ onEvent, appDefinition, appDefinitionChanged, - currentState, appLoading, zoomLevel, setSelectedComponent, diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index 2c11b6e848..ae031d9268 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -59,7 +59,7 @@ import { useDataSourcesStore } from '@/_stores/dataSourcesStore'; import { useDataQueriesStore } from '@/_stores/dataQueriesStore'; import { useAppVersionStore, useAppVersionActions } from '@/_stores/appVersionStore'; import { useQueryPanelStore } from '@/_stores/queryPanelStore'; -import { useCurrentStateStore, useCurrentState, getCurrentState } from '@/_stores/currentStateStore'; +import { useCurrentStateStore, getCurrentState } from '@/_stores/currentStateStore'; import { computeAppDiff, computeComponentPropertyDiff, @@ -184,8 +184,6 @@ const EditorComponent = (props) => { shallow ); - const currentState = useCurrentState(); - const [zoomLevel, setZoomLevel] = useState(1); const [isQueryPaneDragging, setIsQueryPaneDragging] = useState(false); const [isQueryPaneExpanded, setIsQueryPaneExpanded] = useState(false); //!check where this is used @@ -241,7 +239,7 @@ const EditorComponent = (props) => { }); useCurrentStateStore.getState().actions.setCurrentState({ globals: { - ...currentState.globals, + ...getCurrentState().globals, theme: { name: props?.darkMode ? 'dark' : 'light' }, urlparams: JSON.parse(JSON.stringify(queryString.parse(props.location.search))), currentUser: userVars, @@ -621,7 +619,7 @@ const EditorComponent = (props) => { const changeDarkMode = (newMode) => { useCurrentStateStore.getState().actions.setCurrentState({ globals: { - ...currentState.globals, + ...getCurrentState().globals, theme: { name: newMode ? 'dark' : 'light' }, }, }); @@ -1618,7 +1616,7 @@ const EditorComponent = (props) => { }; const globals = { - ...currentState.globals, + ...getCurrentState().globals, }; useCurrentStateStore.getState().actions.setCurrentState({ globals, page }); }; @@ -1660,7 +1658,7 @@ const EditorComponent = (props) => { const queryParamsString = queryParams.map(([key, value]) => `${key}=${value}`).join('&'); const globals = { - ...currentState.globals, + ...getCurrentState().globals, urlparams: JSON.parse(JSON.stringify(queryString.parse(queryParamsString))), }; @@ -2098,7 +2096,7 @@ const EditorComponent = (props) => { {defaultComponentStateComputed && ( <>