Skip to content

Commit c019092

Browse files
authored
Merge pull request #1748 from umbraco/feature/content-type-editor-clean-up-props-on-container-removal
Feat: Content Type editor — remove props when removing container
2 parents 4b7dc33 + 063b201 commit c019092

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/packages/core/content-type/structure/content-type-structure-manager.class.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,15 @@ export class UmbContentTypeStructureManager<
425425
throw new Error('Could not find the Content Type to remove container from');
426426
}
427427
const frozenContainers = contentType.containers ?? [];
428+
const removedContainerIds = frozenContainers
429+
.filter((x) => x.id === containerId || x.parent?.id === containerId)
430+
.map((x) => x.id);
428431
const containers = frozenContainers.filter((x) => x.id !== containerId && x.parent?.id !== containerId);
429432

430-
const frozenProperties = contentType.properties ?? [];
431-
const properties = frozenProperties.filter((x) => x.container?.id !== containerId);
433+
const frozenProperties = contentType.properties;
434+
const properties = frozenProperties.filter((x) =>
435+
x.container ? !removedContainerIds.some((ids) => ids === x.container?.id) : true,
436+
);
432437

433438
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
434439
// @ts-ignore

0 commit comments

Comments
 (0)