From 72d7ed438f2fdbc5670a58e87ab866f783ac2e63 Mon Sep 17 00:00:00 2001 From: NguyenThuyLan <116753400+NguyenThuyLan@users.noreply.github.com> Date: Wed, 5 Nov 2025 19:12:04 +0700 Subject: [PATCH] Property Editors: Hide "add button" when maximum configuration is 1 (fixes #20407) (#20738) Hide add button when max 1 Co-authored-by: Lan Nguyen Thuy --- .../block-grid-entries/block-grid-entries.element.ts | 5 +++++ .../property-editor-ui-block-list.element.ts | 7 ++----- .../input-multiple-text-string.element.ts | 1 + .../components/input-document/input-document.element.ts | 2 +- .../input-rich-media/input-rich-media.element.ts | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entries/block-grid-entries.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entries/block-grid-entries.element.ts index 5392d3e63f..da07777599 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entries/block-grid-entries.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entries/block-grid-entries.element.ts @@ -198,6 +198,9 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen @state() private _isReadOnly: boolean = false; + @state() + private _limitMax?: number; + constructor() { super(); @@ -294,6 +297,7 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen } async #setupRangeValidation(rangeLimit: UmbNumberRangeValueType | undefined) { + this._limitMax = rangeLimit?.max; if (this.#rangeUnderflowValidator) { this.removeValidator(this.#rangeUnderflowValidator); this.#rangeUnderflowValidator = undefined; @@ -408,6 +412,7 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen } #renderCreateButtonGroup() { + if (this._limitMax === 1 && this._layoutEntries.length > 0) return nothing; if (this._areaKey === null || this._layoutEntries.length === 0) { return html` ${this.#renderCreateButton()} ${this.#renderPasteButton()} diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-list/property-editors/block-list-editor/property-editor-ui-block-list.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-list/property-editors/block-list-editor/property-editor-ui-block-list.element.ts index 76b7e263ba..8b48ca9d82 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/block/block-list/property-editors/block-list-editor/property-editor-ui-block-list.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-list/property-editors/block-list-editor/property-editor-ui-block-list.element.ts @@ -394,11 +394,8 @@ export class UmbPropertyEditorUIBlockListElement } #renderCreateButtonGroup() { - if (this.readonly && this._layouts.length > 0) { - return nothing; - } else { - return html`${this.#renderCreateButton()}${this.#renderPasteButton()}`; - } + if (this._layouts.length > 0 && (this._limitMax === 1 || this.readonly)) return nothing; + return html`${this.#renderCreateButton()}${this.#renderPasteButton()}`; } #renderInlineCreateButton(index: number) { diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/components/multiple-text-string-input/input-multiple-text-string.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/components/multiple-text-string-input/input-multiple-text-string.element.ts index 667db17c2c..56307964e6 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/components/multiple-text-string-input/input-multiple-text-string.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/components/multiple-text-string-input/input-multiple-text-string.element.ts @@ -221,6 +221,7 @@ export class UmbInputMultipleTextStringElement extends UmbFormControlMixin 0) return nothing; return html` = this.max) return nothing; + if (this.selection.length > 0 && this.max === 1) return nothing; if (this.readonly && this.selection.length > 0) { return nothing; } else { diff --git a/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-rich-media/input-rich-media.element.ts b/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-rich-media/input-rich-media.element.ts index eddfd3d930..bab80c1176 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-rich-media/input-rich-media.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-rich-media/input-rich-media.element.ts @@ -388,6 +388,7 @@ export class UmbInputRichMediaElement extends UmbFormControlMixin< #renderAddButton() { if (this.readonly) return nothing; + if (this.max === 1 && this._cards.length > 0) return nothing; return html`