From 8058f011ed8b54dca2ce11f567bd0f13435da115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 2 May 2024 10:41:39 +0200 Subject: [PATCH] auto generate alias --- .../components/input-with-alias/input-with-alias.element.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/components/input-with-alias/input-with-alias.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/components/input-with-alias/input-with-alias.element.ts index 8db01ae06d..24f5c0cab7 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/components/input-with-alias/input-with-alias.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/components/input-with-alias/input-with-alias.element.ts @@ -13,6 +13,9 @@ export class UmbInputWithAliasElement extends UmbFormControlMixin(UmbLit @property({ type: String, reflect: false }) alias?: string; + @property({ type: Boolean, attribute: 'auto-generate-alias' }) + autoGenerateAlias?: boolean; + @state() private _aliasLocked = true; @@ -32,7 +35,7 @@ export class UmbInputWithAliasElement extends UmbFormControlMixin(UmbLit const oldName = this.value; const oldAlias = this.alias ?? ''; this.value = event.target.value.toString(); - if (this._aliasLocked) { + if (this.autoGenerateAlias && this._aliasLocked) { // If locked we will update the alias, but only if it matches the generated alias of the old name [NL] const expectedOldAlias = generateAlias(oldName ?? ''); // Only update the alias if the alias matches a generated alias of the old name (otherwise the alias is considered one written by the user.) [NL]