mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 01:18:23 +00:00
Fixes tabs copy pasting and component deletion inside container
This commit is contained in:
parent
f51491df66
commit
026c7cfd12
3 changed files with 9 additions and 9 deletions
|
|
@ -211,6 +211,7 @@ export const getAllChildComponents = (allComponents, parentId) => {
|
|||
|
||||
if (componentParentId === parentId) {
|
||||
let childComponent = deepClone(allComponents[componentId]);
|
||||
childComponent.componentId = componentId;
|
||||
childComponents.push(childComponent);
|
||||
|
||||
// Recursively find children of the current child component
|
||||
|
|
@ -240,7 +241,10 @@ export const copyComponents = ({ isCut = false, isCloning = false }) => {
|
|||
const currentPageId = useStore.getState().getCurrentPageId();
|
||||
// if parent is selected, then remove the parent from the selected components
|
||||
const filteredSelectedComponents = selectedComponents.filter((selectedComponent) => {
|
||||
const parentComponentId = selectedComponent?.component?.parent;
|
||||
const parentComponentId = isChildOfTabsOrCalendar(selectedComponent, allComponents)
|
||||
? selectedComponent.component.parent.split('-').slice(0, -1).join('-')
|
||||
: selectedComponent?.component?.parent;
|
||||
|
||||
if (parentComponentId) {
|
||||
// Check if the parent component is also selected
|
||||
const isParentSelected = selectedComponents.some((comp) => comp.id === parentComponentId);
|
||||
|
|
@ -327,8 +331,7 @@ const updateComponentLayout = (components, parentId, isCut = false) => {
|
|||
|
||||
const isChildOfTabsOrCalendar = (component, allComponents = [], componentParentId = undefined) => {
|
||||
const parentId = componentParentId ?? component.component?.parent?.split('-').slice(0, -1).join('-');
|
||||
|
||||
const parentComponent = allComponents.find((comp) => comp.componentId === parentId);
|
||||
const parentComponent = allComponents?.[parentId];
|
||||
if (parentComponent) {
|
||||
return parentComponent.component.component === 'Tabs' || parentComponent.component.component === 'Calendar';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,10 @@ const DesktopHeader = ({
|
|||
isAppLoaded,
|
||||
changeToDarkMode,
|
||||
}) => {
|
||||
const { editingVersion, showDarkModeToggle, isReleasedVersionId } = useStore(
|
||||
const { showDarkModeToggle, isReleasedVersionId } = useStore(
|
||||
(state) => ({
|
||||
editingVersion: state?.editingVersion,
|
||||
isReleasedVersionId: state?.releasedVersionId == state.editingVersion || state.isVersionReleased,
|
||||
switchDarkMode: state.switchDarkMode,
|
||||
isReleasedVersionId: state?.releasedVersionId == state.selectedVersion?.id || state.isVersionReleased,
|
||||
showDarkModeToggle: state.globalSettings.appMode === 'auto' || !state.globalSettings.appMode,
|
||||
appMode: state.globalSettings.appMode,
|
||||
}),
|
||||
shallow
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1377,7 +1377,7 @@ export const createComponentsSlice = (set, get) => ({
|
|||
const component = {
|
||||
component: allComponents?.[componentId]?.component,
|
||||
layouts: allComponents?.[componentId]?.layouts,
|
||||
parent: allComponents?.[componentId]?.parent,
|
||||
parent: allComponents?.[componentId]?.component?.parent,
|
||||
id: componentId,
|
||||
};
|
||||
_selected.push(component);
|
||||
|
|
|
|||
Loading…
Reference in a new issue