diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts index 429e6277f1..718aca3d3d 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts @@ -295,9 +295,18 @@ export class UmbContentTypeStructureManager< sortOrder: sortOrder ?? 0, }; - const containers = [ - ...(this.#contentTypes.getValue().find((x) => x.unique === contentTypeUnique)?.containers ?? []), - ]; + this.getOwnerContainers(type, parentId)?.forEach((container) => { + if (container.name === '') { + const newName = 'unnamed'; + this.updateContainer(contentTypeUnique, container.id, { + name: this.makeContainerNameUniqueForOwnerContentType(container.id, newName, type, parentId) ?? newName, + }); + } + }); + + + const contentTypes = this.#contentTypes.getValue(); + const containers = [...(contentTypes.find((x) => x.unique === contentTypeUnique)?.containers ?? [])]; containers.push(container); // eslint-disable-next-line @typescript-eslint/ban-ts-comment @@ -333,21 +342,22 @@ export class UmbContentTypeStructureManager< }*/ makeContainerNameUniqueForOwnerContentType( + containerId: string, newName: string, - containerType: UmbPropertyContainerTypes = 'Tab', + containerType: UmbPropertyContainerTypes, parentId: string | null = null, ) { const ownerRootContainers = this.getOwnerContainers(containerType, parentId); //getRootContainers() can't differentiates between compositions and locals + if (!ownerRootContainers) { + return null; + } let changedName = newName; - if (ownerRootContainers) { - while (ownerRootContainers.find((tab) => tab.name === changedName && tab.id !== parentId)) { - changedName = incrementString(changedName); - } - - return changedName === newName ? null : changedName; + while (ownerRootContainers.find((con) => con.name === changedName && con.id !== containerId)) { + changedName = incrementString(changedName); } - return null; + + return changedName === newName ? null : changedName; } async updateContainer( diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-group.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-group.element.ts index fcd24ef4f9..a2ad9a80d4 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-group.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-group.element.ts @@ -92,11 +92,12 @@ export class UmbContentTypeWorkspaceViewEditGroupElement extends UmbLitElement { let newName = (e.target as HTMLInputElement).value; const changedName = this.groupStructureHelper .getStructureManager()! - .makeContainerNameUniqueForOwnerContentType(newName, 'Group', this._group.parent?.id ?? null); + .makeContainerNameUniqueForOwnerContentType(this._group.id, newName, 'Group', this._group.parent?.id ?? null); if (changedName) { newName = changedName; } this._singleValueUpdate('name', newName); + (e.target as HTMLInputElement).value = newName; } render() { @@ -118,7 +119,7 @@ export class UmbContentTypeWorkspaceViewEditGroupElement extends UmbLitElement { diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor.element.ts index 24c5caf40c..fa5090c8f4 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor.element.ts @@ -292,9 +292,9 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements let newName = (event.target as HTMLInputElement).value; const changedName = this.#workspaceContext?.structure.makeContainerNameUniqueForOwnerContentType( + tab.id, newName, 'Tab', - tab.id, ); // Check if it collides with another tab name of this same content-type, if so adjust name: