Skip to content

Commit 9770f43

Browse files
committed
fix: edit on modules view
1 parent 3efe0d5 commit 9770f43

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/shared/components/DynamicPageComponent/DynamicPageComponent.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,17 @@ export const DynamicPageComponent = ({
121121
const [isFormOpen, setIsFormOpen] = useRecoilState(isFormOpenState);
122122
const [searchParams] = useSearchParams();
123123
const showEdit = searchParams.get('showEdit');
124+
const currColumnInfo =
125+
layoutNumber === 'EndColumn'
126+
? layoutColumn.endColumn
127+
: layoutNumber === 'MidColumn'
128+
? layoutColumn.midColumn
129+
: layoutColumn.startColumn;
124130
const [selectedSectionIdState, setSelectedSectionIdState] = useState(
125-
showEdit ? 'edit' : 'view',
131+
showEdit &&
132+
currColumnInfo.resourceName === layoutColumn.showEdit.resourceName
133+
? 'edit'
134+
: 'view',
126135
);
127136

128137
const dynamicPageRef = useRef(null);
@@ -352,6 +361,12 @@ export const DynamicPageComponent = ({
352361
if (isFormOpen.formOpen) {
353362
e.preventDefault();
354363
}
364+
if (
365+
showEdit &&
366+
currColumnInfo.resourceName !== layoutColumn.showEdit.resourceName
367+
) {
368+
return;
369+
}
355370

356371
handleActionIfFormOpen(
357372
isResourceEdited,
@@ -372,11 +387,7 @@ export const DynamicPageComponent = ({
372387
setLayoutColumn({
373388
...layoutColumn,
374389
showEdit: {
375-
...(layoutNumber === 'EndColumn'
376-
? layoutColumn.endColumn
377-
: layoutNumber === 'MidColumn'
378-
? layoutColumn.midColumn
379-
: layoutColumn.startColumn),
390+
...currColumnInfo,
380391
resource: null,
381392
},
382393
});

0 commit comments

Comments
 (0)