fix: fixed issue that caused auto layout alert to popup everytime

This commit is contained in:
Johnson Cherian 2023-12-11 11:11:06 +05:30
parent d605e4ce9c
commit de0cce452b
4 changed files with 10 additions and 4 deletions

View file

@ -289,7 +289,7 @@ export const Container = ({
() => ({
accept: [ItemTypes.BOX, ItemTypes.COMMENT],
async drop(item, monitor) {
if (item.currentLayout === 'mobile' && appDefinition.pages[currentPageId]?.autoComputeLayout) {
if (item.currentLayout === 'mobile' && item.autoComputeLayout) {
turnOffAutoLayout();
return false;
}

View file

@ -110,6 +110,7 @@ export const DraggableBox = React.memo(
selectionInProgress,
isSelectedComponent,
isMultipleComponentsSelected,
autoComputeLayout,
} = useEditorStore(
(state) => ({
currentLayout: state?.currentLayout,
@ -119,6 +120,7 @@ export const DraggableBox = React.memo(
isSelectedComponent:
mode === 'edit' ? state?.selectedComponents?.some((component) => component?.id === id) : false,
isMultipleComponentsSelected: state?.selectedComponents?.length > 1 ? true : false,
autoComputeLayout: state?.appDefinition?.pages?.[state?.currentPageId]?.autoComputeLayout,
}),
shallow
);
@ -136,12 +138,13 @@ export const DraggableBox = React.memo(
layouts,
canvasWidth,
currentLayout,
autoComputeLayout,
},
collect: (monitor) => ({
isDragging: monitor.isDragging(),
}),
}),
[id, title, component, index, currentLayout, zoomLevel, parent, layouts, canvasWidth]
[id, title, component, index, currentLayout, zoomLevel, parent, layouts, canvasWidth, autoComputeLayout]
);
useEffect(() => {

View file

@ -1695,7 +1695,10 @@ const EditorComponent = (props) => {
};
async function turnOffAutoLayout() {
const result = await confirm('Turn off Auto Layout ?', 'Turn off Auto Layout');
const result = await confirm(
'You have to disable auto alignment to manually adjust mobile components. Once disabled, the mobile layout wont automatically align with desktop changes',
'Turn off Auto Layout'
);
if (result) {
turnOffAutoComputeLayout({ pageId: currentPageId, autoComputeLayout: false });
}

View file

@ -324,7 +324,7 @@ export const SubContainer = ({
() => ({
accept: ItemTypes.BOX,
drop(item, monitor) {
if (item.currentLayout === 'mobile' && appDefinition.pages[currentPageId]?.autoComputeLayout) {
if (item.currentLayout === 'mobile' && item.autoComputeLayout) {
turnOffAutoLayout();
return false;
}