From a41c48ad6ca3d879495a265541eb31d395221575 Mon Sep 17 00:00:00 2001 From: NguyenThuyLan <116753400+NguyenThuyLan@users.noreply.github.com> Date: Tue, 25 Nov 2025 17:07:21 +0700 Subject: [PATCH] Multi URL Picker: change validation for url and anchor/querystring (#20920) * Fix validation for url and anchor of multi url picker * fix codesence warning * remove redundant validation --------- Co-authored-by: Lan Nguyen Thuy --- .../link-picker-modal.element.ts | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/multi-url-picker/link-picker-modal/link-picker-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/multi-url-picker/link-picker-modal/link-picker-modal.element.ts index f8cdb79671..e747db814a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/multi-url-picker/link-picker-modal/link-picker-modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/multi-url-picker/link-picker-modal/link-picker-modal.element.ts @@ -8,7 +8,6 @@ import { css, customElement, html, nothing, query, state, when } from '@umbraco- import { isUmbracoFolder, UmbMediaTypeStructureRepository } from '@umbraco-cms/backoffice/media-type'; import { UMB_VALIDATION_CONTEXT, - umbBindToValidation, UmbObserveValidationStateController, UmbValidationContext, type UmbValidator, @@ -42,7 +41,6 @@ class UmbLinkPickerValueValidator extends UmbControllerBase implements UmbValida setValue(value: unknown) { this.#value = value; - this.validate(); } getValue(): unknown { @@ -139,10 +137,22 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement { - validator.setValue(value?.link.type); + const validatorValue = this.#getValidatorValue(value); + + validator.setValue(validatorValue); }); } + #getValidatorValue(value: UmbLinkPickerModalValue | undefined) { + const { type, queryString: anchor, url } = value?.link ?? {}; + const hasContent = anchor || url; + + if (type === 'external') { + return hasContent ? type : null; + } + return type || anchor || null; + } + async #getMediaTypes() { // Get all the media types, excluding the folders, so that files are selectable media items. const mediaTypeStructureRepository = new UmbMediaTypeStructureRepository(this); @@ -183,6 +193,7 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement
${this.#renderLinkTypeSelection()} ${this.#renderDocumentPicker()} ${this.#renderMediaPicker()} @@ -417,9 +430,7 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement ${when( !this.value.link.unique, @@ -449,6 +460,7 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement + @input=${this.#onLinkAnchorInput}> `; }