Skip to content

Commit aa269e3

Browse files
Fix #19675 (#19891)
* clean up old stuff in validation form control mixin * ensure validation trigger when value is changed * Update src/Umbraco.Web.UI.Client/src/packages/property-editors/content-picker/property-editor-ui-content-picker.element.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 2266529 commit aa269e3

File tree

6 files changed

+8
-20
lines changed

6 files changed

+8
-20
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/validation/mixins/form-control.mixin.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,13 @@ export function UmbFormControlMixin<
324324
*/
325325
protected _runValidators() {
326326
this.#validity = {};
327-
//const messages: Set<string> = new Set();
328327
let message: string | undefined = undefined;
329328
let innerFormControlEl: UmbNativeFormControlElement | undefined = undefined;
330329

331330
// Loop through custom validators, currently its intentional to have them overwritten native validity. but might need to be reconsidered (This current way enables to overwrite with custom messages) [NL]
332331
this.#validators.some((validator) => {
333332
if (validator.checkMethod()) {
334333
this.#validity[validator.flagKey] = true;
335-
//messages.add(validator.getMessageMethod());
336334
message = validator.getMessageMethod();
337335
return true;
338336
}
@@ -362,13 +360,7 @@ export function UmbFormControlMixin<
362360
this.#validity.valid = !hasError;
363361

364362
// Transfer the new validityState to the ElementInternals. [NL]
365-
this._internals.setValidity(
366-
this.#validity,
367-
// Turn messages into an array and join them with a comma. [NL]:
368-
//[...messages].join(', '),
369-
message,
370-
innerFormControlEl ?? this.getFormElement() ?? undefined,
371-
);
363+
this._internals.setValidity(this.#validity, message, innerFormControlEl ?? this.getFormElement() ?? undefined);
372364

373365
this.#dispatchValidationState();
374366
}

src/Umbraco.Web.UI.Client/src/packages/documents/documents/components/input-document/input-document.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export class UmbInputDocumentElement extends UmbFormControlMixin<string | undefi
9595
@property({ type: String })
9696
public override set value(selectionString: string | undefined) {
9797
this.selection = splitStringToArray(selectionString);
98+
super.value = selectionString; // Call the parent setter to ensure the value change is triggered in the FormControlMixin. [NL]
9899
}
99100
public override get value(): string | undefined {
100101
return this.selection.length > 0 ? this.selection.join(',') : undefined;

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-media/input-media.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export class UmbInputMediaElement extends UmbFormControlMixin<string | undefined
119119
@property({ type: String })
120120
public override set value(selectionString: string | undefined) {
121121
this.selection = splitStringToArray(selectionString);
122+
super.value = selectionString; // Call the parent setter to ensure the value change is triggered in the FormControlMixin. [NL]
122123
}
123124
public override get value(): string | undefined {
124125
return this.selection.length > 0 ? this.selection.join(',') : undefined;

src/Umbraco.Web.UI.Client/src/packages/members/member/components/input-member/input-member.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export class UmbInputMemberElement extends UmbFormControlMixin<string | undefine
8888
@property({ type: String })
8989
public override set value(selectionString: string | undefined) {
9090
this.selection = splitStringToArray(selectionString);
91+
super.value = selectionString; // Call the parent setter to ensure the value change is triggered in the FormControlMixin. [NL]
9192
}
9293
public override get value(): string | undefined {
9394
return this.selection.length > 0 ? this.selection.join(',') : undefined;

src/Umbraco.Web.UI.Client/src/packages/property-editors/content-picker/components/input-content/input-content.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class UmbInputContentElement extends UmbFormControlMixin<string | undefin
5959
@property({ type: String })
6060
public override set value(selectionString: string | undefined) {
6161
this.#selection = splitStringToArray(selectionString);
62+
super.value = selectionString; // Call the parent setter to ensure the value change is triggered in the FormControlMixin. [NL]
6263
}
6364
public override get value(): string | undefined {
6465
return this.#selection.length > 0 ? this.#selection.join(',') : undefined;

src/Umbraco.Web.UI.Client/src/packages/property-editors/content-picker/property-editor-ui-content-picker.element.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ export class UmbPropertyEditorUIContentPickerElement
2929
extends UmbFormControlMixin<UmbContentPickerValueType | undefined, typeof UmbLitElement>(UmbLitElement, undefined)
3030
implements UmbPropertyEditorUiElement
3131
{
32-
@property({ type: Array })
33-
public override set value(value: UmbContentPickerValueType | undefined) {
34-
this.#value = value;
35-
}
36-
public override get value(): UmbContentPickerValueType | undefined {
37-
return this.#value;
38-
}
39-
#value?: UmbContentPickerValueType = [];
40-
4132
/**
4233
* Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
4334
* @type {boolean}
@@ -94,7 +85,7 @@ export class UmbPropertyEditorUIContentPickerElement
9485
this.#dynamicRoot = startNode.dynamicRoot;
9586

9687
// NOTE: Filter out any items that do not match the entity type. [LK]
97-
this._invalidData = this.#value?.filter((x) => x.type !== this._rootEntityType);
88+
this._invalidData = this.value?.filter((x) => x.type !== this._rootEntityType);
9889
if (this._invalidData?.length) {
9990
this.readonly = true;
10091
}
@@ -119,7 +110,8 @@ export class UmbPropertyEditorUIContentPickerElement
119110
return !isNaN(num) && num > 0 ? num : fallback;
120111
}
121112

122-
override firstUpdated() {
113+
override firstUpdated(changedProperties: Map<string | number | symbol, unknown>) {
114+
super.firstUpdated(changedProperties);
123115
this.addFormControlElement(this.shadowRoot!.querySelector('umb-input-content')!);
124116
this.#setPickerRootUnique();
125117

0 commit comments

Comments
 (0)