Changed function response to handle non accessible components.

This commit is contained in:
devanshu052000 2025-03-07 18:11:29 +05:30
parent 46ab01fead
commit 1ef408f113
2 changed files with 25 additions and 4 deletions

View file

@ -32,8 +32,18 @@ const useCallbackActions = () => {
};
const handleAutoScrollToComponent = (data) => {
const computedComponentId = getComponentIdToAutoScroll(data.id);
if (!computedComponentId) return;
const { isAccessible, computedComponentId, isOnCanvas } = getComponentIdToAutoScroll(data.id);
if (!isAccessible) {
if (isOnCanvas) {
toast.success(
`This component can't be opened because it's on the main canvas. Close ${computedComponentId} and click "Go to component" to view it there`
);
} else
toast.success(
`This component can't be opened because it's inside ${computedComponentId}. Open ${computedComponentId} and click "Go to component"to view it.`
);
return;
}
setSelectedComponents([computedComponentId]);
const target = document.getElementById(computedComponentId);
target.scrollIntoView({ behavior: 'smooth', block: 'nearest' });

View file

@ -103,8 +103,19 @@ export const createLeftSideBarSlice = (set, get) => ({
}
if (modalsOpenOnCanvas.length > 0 && !isInsideOpenModal) {
return undefined;
const targetId = visited.size === 1 ? modalsOpenOnCanvas[modalsOpenOnCanvas.length - 1] : current;
const componentName = currentPageComponents?.[targetId]?.component?.name;
return {
isAccessible: false,
computedComponentId: componentName,
isOnCanvas: visited.size === 1,
};
}
return targetComponentId;
return {
isAccessible: true,
computedComponentId: targetComponentId,
};
},
});