mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 01:18:23 +00:00
Merge pull request #11101 from ToolJet/fix-refactor-copy-pasting-tab
Fixes tabs copy pasting and component deletion inside container
This commit is contained in:
commit
e71843a494
2 changed files with 7 additions and 3 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,8 @@ const updateComponentLayout = (components, parentId, isCut = false) => {
|
|||
|
||||
const isChildOfTabsOrCalendar = (component, allComponents = [], componentParentId = undefined) => {
|
||||
const parentId = componentParentId ?? component.component?.parent?.match(/([a-fA-F0-9-]{36})-(.+)/)?.[1];
|
||||
const parentComponent = allComponents?.[parentId];
|
||||
|
||||
const parentComponent = allComponents.find((comp) => comp.componentId === parentId);
|
||||
if (parentComponent) {
|
||||
return parentComponent.component.component === 'Tabs' || parentComponent.component.component === 'Calendar';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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